Skip to content

fix(control-plane)!: map generated errors to typed OtariError (breaking)#47

Draft
njbrake wants to merge 1 commit into
mainfrom
fix/control-plane-error-mapping
Draft

fix(control-plane)!: map generated errors to typed OtariError (breaking)#47
njbrake wants to merge 1 commit into
mainfrom
fix/control-plane-error-mapping

Conversation

@njbrake

@njbrake njbrake commented Jun 26, 2026

Copy link
Copy Markdown
Member

Note: this PR was drafted by Claude via back-and-forth with @njbrake. The reasoning and decisions are his; the prose is Claude's.

Description

BREAKING CHANGE: control-plane error type. Control-plane methods (keys/users/budgets/pricing/usage) now return Result<T, OtariError> instead of the raw generated Result<T, Error<SomeEndpointError>>.

This makes management calls consistent with the inference path, which already maps HTTP errors to the typed OtariError enum via core::map_error. Every control-plane method now does .await.map_err(map_error). Callers that match on the old generated Error<T> must migrate to OtariError variants (e.g. OtariError::Authentication for 401/403). The raw generated surface remains reachable as an escape hatch via the client config.

Tests / DoD

New integration test maps a generated 401 ResponseError to OtariError::Authentication across one representative method per resource. Local DoD all green: cargo fmt --check, cargo clippy --all-targets -- -D warnings, cargo test --all-features, cargo build, MSRV cargo check --locked.

Fixes #46. Part of the cross-SDK consistency tracked in mozilla-ai/otari#226 (precedent: otari-sdk-python#21). Flagged as breaking; happy to gate behind a version bump or discuss the escape-hatch shape.

AI Usage

This is fully AI-generated (Claude Code, Claude Opus 4.8) via back-and-forth with @njbrake; the diagnosis and decisions are his.

Control-plane methods (keys/users/budgets/pricing/usage) returned the
raw generated `Error<T>` enum, diverging from the inference path which
maps HTTP errors to the typed `OtariError`. Route every control-plane
call through the existing `crate::core::map_error` and return
`crate::error::Result<T>`, making management calls consistent with
inference.

BREAKING CHANGE: control-plane methods now return
`Result<T, OtariError>` instead of `Result<T, Error<SomeEndpointError>>`.
Callers matching the old generated error type must update. The generated
core stays reachable via `ControlPlane::config()` for callers needing the
raw `Error<T>`.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

Control-plane methods return the raw generated Error<T> instead of typed OtariError (breaking fix)

1 participant