fix: actionable error message for invalid DataForSEO API keys#53
Merged
Merged
Conversation
…of "unexpected error" An invalid or mis-encoded DATAFORSEO_API_KEY currently surfaces as "An unexpected error occurred. Please check server logs and try again." because the 401 from DataForSEO maps to the generic INTERNAL_ERROR code. Since the key must be the base64 of login:password, pasting the raw credentials is a common setup mistake and this is likely the first error a new self-hoster ever sees. - Add a DATAFORSEO_AUTH_FAILED error code with the client message "DataForSEO rejected the API key. Check that DATAFORSEO_API_KEY is the base64 of your DataForSEO login:password." - Map HTTP 401/403 to it in fetchDataforseoAccountState (the /v3/appendix/user_data probe used by the backlinks and AI access checks), and HTTP 401 in the shared SDK transport in dataforseo/core.ts so every feature path benefits. Verified live: with an invalid key the backlinks page now shows the actionable message; with a valid key behavior is unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
An invalid or mis-encoded
DATAFORSEO_API_KEYcurrently surfaces as "An unexpected error occurred. Please check server logs and try again." because DataForSEO's 401 maps to the genericINTERNAL_ERRORcode. Since the key must be the base64 oflogin:password, pasting raw credentials (or a wrong password) is a common setup mistake, and this is likely the first error a brand-new self-hoster ever sees.DATAFORSEO_AUTH_FAILEDerror code with the client message: "DataForSEO rejected the API key. Check that DATAFORSEO_API_KEY is the base64 of your DataForSEO login:password."fetchDataforseoAccountState(the/v3/appendix/user_dataprobe behind the backlinks/AI access checks), and HTTP 401 in the shared SDK transport (dataforseo/core.ts) so every feature path benefits.Verification
tsc --noEmit,prettier --check, and the error-code/error-message/dataforseo test suites pass.🤖 Generated with Claude Code