feat: RFC 9457 error responses with tests - #14
Closed
Taure wants to merge 7 commits into
Closed
Conversation
Use json:encode/1 and json:decode/1 directly instead of the configurable json_lib approach via nova:get_env. The json_lib config option was removed from Nova. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Update pre_request/post_request to 4-arity callbacks matching the current nova_plugin behaviour. Update plugin_info to return a map instead of a tuple. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Wrap validation errors in RFC 9457 Problem Details envelope (type, title, status, detail, errors) - Default status code changed from 400 to 422 (configurable via status_code option for backwards compatibility) - Set Content-Type to application/problem+json on error responses - Add JSON Pointer (RFC 6901) paths for field locations - Normalize error keys to path, message, type, actual_value, expected - Handle all Jesse error types (schema_invalid, data_error, schema_error) instead of only data_invalid - Guard file:read_file in validate_json to return clean error on missing schema files instead of crashing - Add group_by_field option to group errors by field path for form-friendly consumption - Bump version to 0.3.0 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add 56 EUnit tests covering RFC 9457 error rendering, JSON pointer generation, format messages, pre_request/post_request callbacks, and validate_json with jesse integration. Fix bug where binary schema keys passed to jesse:validate would crash with function_clause since jesse_database:load/1 only accepts lists. Add ensure_list/1 helper to convert binary keys. Update nova dep to 0.13.7, add meck test dep, xref_ignores for plugin callbacks, rebar3_audit and rebar3_sbom plugins.
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.
Summary
jsonmodulepre_request/4,post_request/4)init/0callback to start jesse database and preload schemasapplication/problem+jsonerror responses with configurable status codesgroup_by_fieldoption to group validation errors by JSON pointer pathjesse:validate(jesse'sload/1only accepts lists)Test plan