fix: prevent struct errors from hitting plain-map normalize_error clause#240
Open
jscheid wants to merge 1 commit intoagentjido:mainfrom
Open
fix: prevent struct errors from hitting plain-map normalize_error clause#240jscheid wants to merge 1 commit intoagentjido:mainfrom
normalize_error clause#240jscheid wants to merge 1 commit intoagentjido:mainfrom
Conversation
The normalize_error clause for %{message: message} matches any map
with a :message key — including exception structs. When a struct
hit this clause, Map.drop preserved __struct__ and __exception__
in the details, producing a map that masquerades as a struct but
has the wrong fields. Downstream JSON encoding then crashes on
the malformed map.
Add `not is_struct(error)` guard so structs dispatch to the
dedicated struct clause, which uses Jido.Error.to_map for proper
field extraction. Two tests that asserted :execution_error for
InvalidInputError now correctly expect :validation_error.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
|
Leaving this open for now. We added the underlying transport-sanitizer foundation in agentjido/jido_action#134, and I think this As written, the |
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.
The
normalize_errorclause for%{message: message}matches any map with a:messagekey — including exception structs. When a struct hit this clause,Map.droppreserved__struct__and__exception__in the details, producing a map that masquerades as a struct but has the wrong fields. Downstream JSON encoding then crashes on the malformed map.Add
not is_struct(error)guard so structs dispatch to the dedicated struct clause, which usesJido.Error.to_mapfor proper field extraction. Two tests that asserted:execution_errorforInvalidInputErrornow correctly expect:validation_error.