Repository navigation
feat!: every error keeps its cause - #280
Closed
cunninghamcard-bit wants to merge 2 commits into
Closed
cunninghamcard-bit wants to merge 2 commits into
cunninghamcard-bit wants to merge 2 commits into
Conversation
Every error whose AI SDK class takes `cause` now has one, and it is what `source()` returns: a nested `AiMuxError`, or a `SourceError` snapshot of a foreign error's `source()` chain. The JSON payload carries the same chain and each binding exposes it natively. Transport errors drop the URL. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S2GJxE3fH7rQvAwXLg2f1C
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S2GJxE3fH7rQvAwXLg2f1C
cunninghamcard-bit
marked this pull request as ready for review
October 19, 2026 08:51
This was referenced Oct 19, 2026
Merged
Contributor
Author
|
这个原型太大,按 RFC-0047(#286)拆成了三个叠起来的 PR,内容都搬过去了,这里关闭:
Generated by Claude Code |
4 of 7 tasks
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.
Requested by li · project thread
Summary
Before: an error kept only one line of text. A refused connection read
error sending request for url (http://…?key=…): the OS reason was gone and the query (which may hold an API key) was in the message. Parse, validation, URL, base64 and download failures wereformat!ed into strings,InvalidToolInput.causewas a string, and no binding exposed a cause.After: every error whose AI SDK class takes
causehas one, and it is whatsource()returns.anyhow/{:#}prints the whole chain down toConnection refused (os error 111); the JSON payload carries the same chain ascause, and each binding exposes it natively (Nodeerror.cause, Python__cause__, Java/KotlingetCause(), GoUnwrap(), Swift/Fluttercause, C++aimux::NativeError::json()). Transport errors drop the URL. Messages are unchanged.How: a cause is either a nested
AiMuxError(kept whole, like the AI SDK nesting aJSONParseErrorin anAPICallError) or aSourceError, a cloneable, serializable{ message, cause? }snapshot of a foreign error'ssource()chain.AiMuxErrorstays on thiserror with#[source]on eachcause;Retryis transparent andRetryError::source()is the last attempt (lastError),ApiCallError::source()itscause. The string variantsJsonParse,NoOutputGenerated,InvalidResponseData,InvalidArgument,InvalidPromptandOtherbecome{ message, cause }withAiMuxError::json_parse(..)-style constructors, and every site that had the underlying error now passes it.FetchErrorcarries aSourceErrorbuilt fromreqwest::Error::without_url().Registered in
docs/ai-sdk-request-pipeline.md§3 (replacing "cause本轮不加入"): messages still include the underlying text, because the C ABI message getter only sees the message; ops binding/protocol/recording errors take nocause, their reason is one level and already in the message and payload.docs/error-model.mdgains the per-language table.Type of change
Checklist
cargo fmt --all -- --checkpassescargo clippy --workspace --all-targets -- -D warningspassescargo test --workspacepasses (cassette playback — no network/keys)README.md,docs/,rfc/,bindings/README.md)Notes for reviewers
Variant(msg)patterns toVariant { message, .. }. The real changes areaimux-core/src/error.rs,aimux-provider-utils/src/{fetch,handle_fetch_error,post_to_api,response_handler,http,ws}.rs,aimux-core/src/{output,parse_tool_call}.rsand the binding error modules.contract-tests/ops/errors/aimux-api-call.json(a transport chain) andaimux-invalid-response-data.json(a nestedAI_JSONParseError) now carry acause;aimux-invalid-tool-input.jsonhas its cause as an object.source()chain and wire round trip with and without a cause, a real refused connection (chain kept, URL gone), serde and retry sources, and a cause test per binding (Node, Python, Java, Go, Swift, Flutter, C++).Generated by Claude Code