fix(control-plane)!: map generated errors to typed OtariError (breaking)#47
Draft
njbrake wants to merge 1 commit into
Draft
fix(control-plane)!: map generated errors to typed OtariError (breaking)#47njbrake wants to merge 1 commit into
njbrake wants to merge 1 commit into
Conversation
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>
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.
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
This makes management calls consistent with the inference path, which already maps HTTP errors to the typed
OtariErrorenum viacore::map_error. Every control-plane method now does.await.map_err(map_error). Callers that match on the old generatedError<T>must migrate toOtariErrorvariants (e.g.OtariError::Authenticationfor 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
ResponseErrortoOtariError::Authenticationacross one representative method per resource. Local DoD all green:cargo fmt --check,cargo clippy --all-targets -- -D warnings,cargo test --all-features,cargo build, MSRVcargo 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.