CBOR store: fall back to ignore for non-binary tagged items - #5383
CBOR store: fall back to ignore for non-binary tagged items#5383ameliabarnabyhub wants to merge 3 commits into
Conversation
Signed-off-by: ameliabarnabyhub <ameliabarnabyhub@users.noreply.github.com>
Signed-off-by: ameliabarnabyhub <ameliabarnabyhub@users.noreply.github.com>
Signed-off-by: ameliabarnabyhub <ameliabarnabyhub@users.noreply.github.com>
🔴 Amalgamation check failed! 🔴The source code has not been amalgamated and/or formatted correctly. 📎 A ready-to-apply patch is attached to the failed workflow run as the git apply amalgamation.patchThis does not require installing astyle yourself. |
nlohmann
left a comment
There was a problem hiding this comment.
Found two correctness issues while reviewing this PR:
1. single_include/nlohmann/json.hpp has diverged from include/ (most severe — likely root cause of the CI failures)
The amalgamation commit adds new logic (throw_on_discarded(), assert_msgpack_size(), discarded values now throwing type_error.318 instead of producing empty output) that never landed in include/nlohmann/detail/output/binary_writer.hpp. That header still has the old break;/JSON_ASSERT(false) paths — confirmed against develop and against this PR's diff, which only touches binary_reader.hpp, single_include/json.hpp, and tests/src/unit-cbor.cpp, never binary_writer.hpp.
Since the test suite compiles against include/, the updated discarded-value tests in tests/src/unit-cbor.cpp (expecting CHECK_THROWS_WITH_AS(...type_error.318...)) can't pass. This lines up with essentially every CI check failing on this PR, including ci_test_amalgamation.
2. The CBOR fix itself has a nested-tag regression
In include/nlohmann/detail/input/binary_reader.hpp (~line 904), the fallback for a non-binary tagged item under store mode hardcodes:
return parse_cbor_internal(false, cbor_tag_handler_t::ignore);instead of propagating the enclosing tag_handler (which is store here). So tag(100) -> [tag(80) -> h'01'] parsed under store mode loses the inner tag's subtype, because everything inside the non-binary wrapper now gets parsed with ignore instead of store. Passing tag_handler through instead of the literal ignore should fix this without changing the intended behavior for the top-level non-binary tag.
Posted by Claude Code on behalf of @nlohmann.
Fixes #5316 (part 1)
cbor_tag_handler_t::storeassumed every tagged item is a byte string. Tagged maps, arrays, and other non-binary values therefore failed withparse_error.113even thoughignoreaccepted the same input (notably CBOR self-describe tag 55799).When the tagged item is not a binary head byte, fall back to
ignoreparsing instead of forcing binary decoding. Binary tags still store the subtype as before.Does not change behavior for tag numbers 6–20 over binary strings (part 2 of #5316).