Skip to content

[Fix] Parse flat PublicError responses in the SDK - #37

Merged
marcelo-cm merged 3 commits into
mainfrom
marcelo-fix-public-error-parsing
Aug 12, 2026
Merged

[Fix] Parse flat PublicError responses in the SDK#37
marcelo-cm merged 3 commits into
mainfrom
marcelo-fix-public-error-parsing

Conversation

@marcelo-cm

@marcelo-cm marcelo-cm commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Teach to_api_error / APIStatusError to understand Flask PublicError payloads: {error, message, metadata}
  • Keep support for nested developer-API envelopes and legacy bare/enriched codes
  • Prefer OAuth error_description when present
  • Map PublicError metadata (and legacy top-level fields like minimum_tier / denied_keys) into .details
  • Add login + parser tests so tier denials print the server message and do not save credentials
  • No CLI _ERROR_HINTS table — recovery copy stays server-owned

Context

Fixes the user-visible issue from gumloop-py#35 / PR #36 without maintaining client-side product copy.

Companion backend PR: https://github.com/gumloop/gumloop_backend/pull/6995

Note: FastAPI {"detail": {...}} envelopes are intentionally not unwrapped; this SDK talks to the Flask public API.

Test plan

  • uv run pytest tests/sdk/test_errors.py tests/cli/test_login.py tests/sdk/test_client.py tests/cli/test_sync_contract_fixtures.py -q
  • Against the backend companion: gumloop login with a free-tier account prints the upgrade message and does not save credentials
  • Nested developer-API errors (e.g. sync fixtures) still expose .code / .details

CLI login was falling back to a bare HTTP status when the API returned
a flat {error, message, metadata} body. Teach to_api_error to read
PublicError, OAuth error_description, and legacy top-level context so
the CLI can print the server message without a local hint table.
Auth-layer subscription_tier_required responses carry minimum_tier only,
not a fake gumloop_api denied_key.
@marcelo-cm
marcelo-cm merged commit 30ef60c into main Aug 12, 2026
9 checks passed
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