Skip to content

feat(errors): add code + request_id to DevhelmApiError#5

Merged
caballeto merged 3 commits into
mainfrom
chore/codegen-audit-phase-2
Apr 22, 2026
Merged

feat(errors): add code + request_id to DevhelmApiError#5
caballeto merged 3 commits into
mainfrom
chore/codegen-audit-phase-2

Conversation

@caballeto
Copy link
Copy Markdown
Member

Summary

  • DevhelmApiError now carries code (machine-readable category, e.g. NOT_FOUND) and request_id (mirrors the X-Request-Id response header) for support correlation.
  • error_from_response parses the canonical ErrorResponse envelope ({status, code, message, requestId}); the X-Request-Id header value wins when both are present.
  • DevhelmTransportError preserves the underlying httpx exception via __cause__.
  • Drops the legacy AuthError alias and surfaces typed subclasses (DevhelmAuthError, DevhelmNotFoundError, DevhelmConflictError, DevhelmRateLimitError, DevhelmServerError).
  • Bumps to 0.1.3 so mcp-server's devhelm>=0.1.3 floor resolves.
  • Regenerated schemas pull through SubscribedEventStrEnum and the new ErrorResponse shape (code required, requestId nullable).

Test plan

  • pytest tests/ (705 passed, 1 skipped)
  • mono surface tests (tests/surfaces/sdk_python/test_errors.py) green against the new API contract

Made with Cursor

…ed taxonomy

- DevhelmApiError now carries `code` (machine-readable category) and
  `request_id` (from X-Request-Id header) for support correlation
- error_from_response extracts both from the canonical ErrorResponse
  envelope; header value wins when present
- DevhelmTransportError preserves underlying httpx exception on __cause__
- Drop legacy AuthError alias; surface DevhelmAuthError /
  DevhelmNotFoundError / DevhelmConflictError / DevhelmRateLimitError /
  DevhelmServerError as ergonomic subclasses of DevhelmApiError
- Bump to 0.1.3 to match mcp-server dependency floor
- Regenerated schemas pull through SubscribedEvent → StrEnum + the new
  ErrorResponse fields (code required, requestId nullable)

Made-with: Cursor
The SDK's typed errors all gained a server-supplied `code` in the prior
batch, but only `DevhelmApiError` exposed it. That left callers writing
two-prong checks — `isinstance` for category, then `code` for sub-type —
which defeats the point of the canonical envelope.

Promote `code` to `DevhelmError` so every subclass carries a non-empty
machine-readable category by construction:

  - DevhelmValidationError → "VALIDATION"
  - DevhelmTransportError  → "TRANSPORT"
  - DevhelmApiError        → server-supplied (e.g. "NOT_FOUND") or the
                             "API_ERROR" sentinel when the response
                             didn't conform to the canonical envelope

`err.code` is now always a `str` — no more `Optional[str]`, no more
`if err.code is not None`. Update the two tests that previously
asserted `err.code is None` for non-conforming bodies; they now assert
the `API_ERROR` fallback.

Also picks up the regenerated Pydantic models for the optional
`isDefault` field on `CreateEnvironmentRequest` (sourced from the mono
spec change in the same series).

Made-with: Cursor
@caballeto caballeto merged commit 5dcbb92 into main Apr 22, 2026
4 checks passed
@caballeto caballeto deleted the chore/codegen-audit-phase-2 branch April 22, 2026 08:25
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.

1 participant