Skip to content

[NekosBest] return None on failed API call, guard empty results. - #238

Merged
ltzmax merged 2 commits into
ltzmax:masterfrom
Evanroby:nekosbest-1
Jul 12, 2026
Merged

[NekosBest] return None on failed API call, guard empty results.#238
ltzmax merged 2 commits into
ltzmax:masterfrom
Evanroby:nekosbest-1

Conversation

@Evanroby

Copy link
Copy Markdown
Contributor

_api_call returned the sent error Message instead of None on non-200 responses, so if url is None never caught it and the code went on to index into the Message, raising TypeError: 'Message' object is not subscriptable.

  • _api_call now sends the error message and returns None
  • embedgen/imgembedgen guard against an empty results list (e.g. API returns 200 with no data) before indexing [0]
  • the empty-results check in embedgen runs before usage counters are incremented, so failed calls aren't counted as uses

@ltzmax

ltzmax commented Jul 12, 2026

Copy link
Copy Markdown
Owner

Well, its mostly correct from begin of, its just the enforcement of required User-Agent that was needed since last month which i never did cause i keep forgetting
https://docs.nekos.best/getting-started/api-reference.html#user-agent

@ltzmax ltzmax added Type: Bug fix Bug fixes Cog: NekosBest This is for the nekosbest cog labels Jul 12, 2026
@Evanroby

Copy link
Copy Markdown
Contributor Author

What do you want to use for the User-Agent ? You can still push commits on my branch.

@ltzmax

ltzmax commented Jul 12, 2026

Copy link
Copy Markdown
Owner

What do you want to use for the User-Agent ? You can still push commits on my branch.

It was enforced by the Neko's devs to have user agents so it's needed to be done someday, I'll just use this temporary fix for now until I remember doing it

@ltzmax
ltzmax merged commit 4acc7d1 into ltzmax:master Jul 12, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Cog: NekosBest This is for the nekosbest cog Type: Bug fix Bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants