refactor: default to OTP json, drop thoas dependency#386
Open
Taure wants to merge 1 commit into
Open
Conversation
f68af61 to
ceec233
Compare
Switch the default json_lib from thoas to the OTP json module and remove
thoas from the dependency list. The json_lib config remains so users can
plug in any module that follows the OTP contract:
encode/1 -> binary() | iodata(), decode/1 -> Term (raises on bad input).
- nova_request_plugin: wrap decode/1 in try/catch to keep 400 responses
on malformed JSON.
- nova_jsonlogger: wrap encode/2 output in iolist_to_binary/1 so the
formatter still returns a binary regardless of backend.
- Update inline tests to the OTP json contract (no {ok, _} wrapper).
- Update configuration guide to document the new default and contract.
ceec233 to
6b13d49
Compare
burbas
requested changes
May 26, 2026
Contributor
burbas
left a comment
There was a problem hiding this comment.
We need to have a discussion when to use try..catch for these kinds of operations and when not to.
| {ok, JSON} -> | ||
| modulate_state(Req#{json => JSON}, Tl, State); | ||
| Error -> | ||
| JsonLib = nova:get_env(json_lib, json), |
Contributor
There was a problem hiding this comment.
I add my comment to this block since it showcase my point;
Here we do try...catch but in the rest of the code we just let it crash. That we can not have - we need to discuss a strategy on how to handle these kinds of problems. Do we crash or do we catch it? It might be that we want to do different things in different situations - but think we need to discuss this more broadly.
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
json_libfromthoasto the OTPjsonmodule and removesthoasfrom the dependency list.json_libremains configurable so users can plug in any module that follows the OTP contract:encode/1 -> binary() | iodata(),decode/1 -> Term(raises on bad input).nova_request_pluginwrapsdecode/1intry/catchto keep returning 400 on malformed JSON.nova_jsonlogger:encode/2wraps its output iniolist_to_binary/1so the formatter still returns a binary regardless of backend.Test plan
rebar3 compilerebar3 xrefrebar3 dialyzerrebar3 eunit(8/0 — same as master baseline)