Repository navigation
Report property name as found in input in deserialization error paths - #368
Open
cowtowncoder wants to merge 9 commits into
Open
cowtowncoder wants to merge 9 commits into
cowtowncoder wants to merge 9 commits into
Conversation
Companion to FasterXML/jackson-databind#6364: Afterburner and Blackbird now report the same name as stock deserializers when a property value fails. Also stops `SuperSonicBeanDeserializer` from wrapping failures of `_deserializeDisordered()` twice, which added a bogus path segment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reading of property names and value tokens is no longer within `try` blocks that blame a property, so parser failures have no path, as with stock deserializers. Applies to both `SuperSonicBeanDeserializer` and `SuperSonicUnrolledDeserializer`. `_deserializeDisordered()` only reads the input name for beans with aliases or case-insensitive matching, at the value token, and goes through `_failedPropertyName()`, same as stock and Blackbird. Tests now also cover `deserializeFromObject()` and update from a property name, which `orderedFromPropertyName` did not reach, plus case-insensitive matching, structured values, unknown properties and problem handler failures. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…y codegen `BBCodecStockChecksTest` now compares failures against stock for aliased properties with structured values (child codecs, stock reads, field stores, failing setters) and under an active view. Codegen: drop the `Names` record for a plain slot that is negative when unused, so record codecs only allocate it when needed, and name the `inputName` local of record codecs in debug metadata, as for POJO codecs. `AliasErrorPathTest` mapper now comes from the test base helper. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The fast path of these overrides needs vanilla processing, but databind only calls `deserializeFromObject()` for non-vanilla deserializers, for which the overrides just delegated to `super`. Removes them from both `SuperSonicBeanDeserializer` and `SuperSonicUnrolledDeserializer`, along with the test that reached them through a direct call. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ow does jackson-databind#6373 (partial fix of #6357) made stock's `_vanillaDeserializeWithUnknown()` report a token that is neither a name nor END_OBJECT, instead of returning the bean. Generated POJO codecs copied the old behavior, so `BBReaderOddTokenTest` fails with databind snapshots that have the change. Removes the tracking of unknown names from generated code, and the `vanillaLoop` plan flag that was only used for it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`_readAndSet()` put all `deserializeAndSet()` calls on one call site, which would mix the type profiles of all properties on Afterburner's hot path. Each property has its own call site again, with parser calls still out of `try`. `SuperSonicBeanDeserializer.deserialize(p, ctxt, bean)` failed on a token that is neither START_OBJECT nor PROPERTY_NAME, for example with `readerForUpdating()` or `@JsonMerge` and a scalar value. It now leaves the bean as is, same as stock and `SuperSonicUnrolledDeserializer`. `UnknownProperty343Test` only went through stock databind: adds vanilla and update cases that reach Afterburner's own code. Minor `AliasErrorPathTest` cleanup. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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
Companion to FasterXML/jackson-databind#6364 (now merged), which makes stock deserializers report a failing property under the name found in input (alias, or other case with case-insensitive matching). Without this PR, the same input gives a different error path depending on whether Afterburner or Blackbird is used.
Needs a jackson-databind snapshot with #6364 and #6373 (build 154 or later): Afterburner and Blackbird both use the new
BeanDeserializerBase._failedPropertyName(), and Blackbird'sBBReaderOddTokenTestexpects stock to report the token that #6373 covers.Afterburner
_deserializeDisordered()reports the input name. As in Blackbird, it only reads that name for beans with aliases or case-insensitive matching; it reads it at the value token, as stock does, and goes through_failedPropertyName().SuperSonicBeanDeserializercalled_deserializeDisordered()inside thetryof its fast path, so a failure there was wrapped twice. For a bean with more than 6 properties,{"a":"bad"}whereais not the first ordered property, or any alias, got a bogus extra path segment such as["a","a1"]. Those calls are now outside thetry.tryblocks, in bothSuperSonicBeanDeserializerandSuperSonicUnrolledDeserializer.{"a":1, badused to blamea, which had parsed successfully. Each property keeps its owndeserializeAndSet()call site, for type profiles.SuperSonicBeanDeserializer.deserialize(p, ctxt, bean)failed on a token that is neitherSTART_OBJECTnorPROPERTY_NAME, for examplereaderForUpdating(bean).readValue("12")or a@JsonMergeproperty with a scalar value. It now leaves the bean as is, same as stock andSuperSonicUnrolledDeserializer.deserializeFromObject()overrides of both deserializers. Their fast path needed vanilla processing, but databind only calls this method for non-vanilla deserializers, for which they just delegated tosuper. With the fast path made to throw, only a test calling it directly reached it.Behavior changes, both matching stock:
IllegalStateExceptionthrown by aDeserializationProblemHandler, are no longer wrapped inDatabindExceptionfor beans with more than 6 properties.One more change, for external code calling
deserializeFromObject()directly on these deserializers: atSTART_OBJECTit now returns an empty bean, as the stock method does, instead of reading properties. Databind advances the parser before calling this method, and nothing in databind or this repo makes such a call.Blackbird
startObjector view checks, since stock now reports the input name on all its loops. That removes the extra local and the_failedName()rules.END_OBJECTafter an unknown property, instead of returning the bean. This also fixes theBBReaderOddTokenTestfailure that the databind rebuild on3.xhas. JSON input cannot produce such a token; aTokenBufferor non-JSON parser can. Removes the unknown-name tracking and thevanillaLoopplan flag. Record codecs still end their loop on such a token, as stock's property-based loop does until the rest of #6357 is fixed.Testing
./mvnw verify -pl afterburner,afterburner-testspasses with JDK 17, and-pl blackbird,blackbird-tests,blackbird-jpms-tests -Dblackbird.test.oldJdks=...with JDK 25, plus 17 and 21 for the old-JDK runtime tests. CI covers all modules and JDKs../mvnw verifyon all of jackson-modules-base with JDK 25 passed against jackson-databind#6364 installed into a scratch copy of the local Maven repository.AliasErrorPathTestcovers both optimized deserializers (withDEFAULT_VIEW_INCLUSIONenabled, which they need), including aliases, case-insensitive matching, structured values, unknown properties, problem handler failures, parser failures and update from a non-Object token. A stack frame check confirms the update-from-property-name route.UnknownProperty343Testnow has vanilla and update cases for a trailing unknown property, which reach Afterburner's own code. Breaking that handling or the update-from-non-Object fix in a scratch copy makes the new tests fail._deserializeDisordered(), since JSON gives the same result either way.BBCodecStockChecksTestcases compare POJO and record failures against stock, with default settings, vanilla settings and case-insensitive matching, for structured values (child codecs, stock reads, field stores, failing setters) and under an active view. Removing the input name read from the codegen in a scratch copy makes them fail.inputNamedebug name of record codecs, as no test checks debug metadata.🤖 Generated with Claude Code