-
Notifications
You must be signed in to change notification settings - Fork 513
feat: add field context to encoding errors #5618
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Replace TestEncodingStrategy with ErrorOnFieldEncodingStrategy that wraps StructuralEncodingStrategy - Use nested struct schema (outer.inner) to test field path context - Update expected error format to include field path - Remove obsolete TODOs 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Add EncodingFailed error variant that wraps encoding errors with the field name. This helps users identify which field caused an encoding failure. Errors are wrapped in both phases: - Task creation (maybe_encode returns error) - Task execution (EncodeTask future resolves to error) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
StructStructuralEncoder now wraps child encoder errors with the child field name. This enables error messages to show the full field path for errors in nested struct fields (e.g., "outer" -> "inner"). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Error messages now show field IDs alongside names: "failed to encode field `outer (id: 0)`" 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Code ReviewThis PR adds field context to encoding errors, which is useful for debugging. The implementation is solid overall. P1 Issues
Minor Observations
|
Changes SummaryThis PR improves error reporting for encoding failures by wrapping errors with field context (name and ID). Both synchronous encoding errors (during task creation) and asynchronous errors (during task execution) are wrapped with field context, providing better diagnostics for complex schemas with nested structs. Type: feature Components Affected: error handling, struct encoding, file writing, field encoder interface Files Changed
Architecture Impact
Risk Areas: Error wrapping introduces additional allocations for async closures that capture field_desc strings, Breaking change to StructStructuralEncoder::new() requires updates in all callers, Potential for error message duplication if nested wrapping occurs multiple times, The location!() macro is called multiple times per field, creating many location captures with potential overhead Suggestions
Full review in progress... | Powered by diffray |
Summary
Encoding errors now include field context to help identify which field caused the error. This is useful for debugging encoding issues in complex schemas.
failed to encode fieldouter (id: 0)``)Example error output:
🤖 Generated with Claude Code