Skip to content

fix: actionable error message for invalid DataForSEO API keys#53

Merged
bensenescu merged 1 commit into
every-app:mainfrom
mattmacrocket:pr/dataforseo-auth-error
Jul 2, 2026
Merged

fix: actionable error message for invalid DataForSEO API keys#53
bensenescu merged 1 commit into
every-app:mainfrom
mattmacrocket:pr/dataforseo-auth-error

Conversation

@mattmacrocket

Copy link
Copy Markdown
Contributor

What

An invalid or mis-encoded DATAFORSEO_API_KEY currently surfaces as "An unexpected error occurred. Please check server logs and try again." because DataForSEO's 401 maps to the generic INTERNAL_ERROR code. Since the key must be the base64 of login: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.

  • Adds 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."
  • Maps HTTP 401/403 to it in fetchDataforseoAccountState (the /v3/appendix/user_data probe behind the backlinks/AI access checks), and HTTP 401 in the shared SDK transport (dataforseo/core.ts) so every feature path benefits.

Verification

  • Live-tested both ways: with an invalid key, the backlinks page shows the actionable message (previously the generic one); with a valid key, behavior is unchanged.
  • tsc --noEmit, prettier --check, and the error-code/error-message/dataforseo test suites pass.

🤖 Generated with Claude Code

…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>
@bensenescu bensenescu merged commit c8a1e17 into every-app:main Jul 2, 2026
2 checks passed
@mattmacrocket mattmacrocket deleted the pr/dataforseo-auth-error branch July 4, 2026 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants