Skip to content

Add DynamoDBTypeConvertedJson annotation back, without relying on jackson-databind - #7576

Open
RanVaknin wants to merge 3 commits into
feature/master/DDB-mapperv2from
rvaknin/add-DynamoDBTypeConvertedJson-back
Open

RanVaknin wants to merge 3 commits into
feature/master/DDB-mapperv2from
rvaknin/add-DynamoDBTypeConvertedJson-back

Conversation

@RanVaknin

@RanVaknin RanVaknin commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Motivation and Context

PR #7502 removed S3link which transitively brought in jackson-databind. As a result DynamoDBTypeConvertedJson broke since it relies on databind for reflection, applying ruleset and writing / read to and from JSON.

The team has decided to not rely on databind directly because of large number of CVEs it has associated with it, and instead reflectively find the objectmapper class that should be on a customer's classpath when they have this annotation. This avoids any direct or optional dependencies on databind, but it would mean a runtime failure for customers who use this annotation but do not bring this dependency themselves.

Modifications

This PR has 2 commits:

  1. 7412384 - is just a verbatim copy and bring back of the removed annotation and tests.
  2. f9cd5c6 - this is where the changes are for this PR and so this is the Commit that provides the actual diff.
  3. e7322fe adds the v1 fixture compliance tests.

Since we don't want to depend on jackson-databind, we can get around it by reflectively examining the class loader for databind's ObjectMapper class. and calls it through reflection. This allows customers who do not use this annotation to not have a dependency on databind, and customers who do use this annotation to provide their own databind or fail at runtime.

For reference, Apache Groovy does the same thing.

Alternative considered:

I have considered just making jackson-databind optional, but that would still list it in the mapper's published pom, where scanners would flag its CVEs on the mapper artifact.

Testing

We still must depend on databind as a test dependency.

Aside from the tests that were pre-existing before #7502

  1. A dedicated test run that removes databind from the classpath to confirm the mapper works without it and raises a clear error.
  2. a suite of fixtures tests that have been generated using the v1 SDK acting as byte for byte compliance to make sure v2 doesnt introduce breaking behaviors.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance improvement (non-breaking change which improves latency, throughput, or resource use)
  • Deprecation (marks existing functionality as deprecated)
  • Removal (removes previously deprecated functionality)
  • Documentation (changes to documentation only)
  • Other (tests, build, CI, or refactoring with no customer-visible change)

Checklist

AI tools

  • I wrote this pull request description myself, not with an AI tool
  • I have reviewed all changes in this pull request myself, including any generated by AI tools

License

  • I confirm that this pull request can be released under the Apache 2 license

Restore @DynamoDBTypeConvertedJson and its tests exactly as they were
at f8d9c8c, before #7502 removed them, so the next commit shows
only the changes needed to drop the jackson-databind dependency.

This commit does not compile on its own: the annotation still imports
jackson-databind, which the mapper no longer depends on.
Call jackson-databind through reflection instead of depending on it, so
the mapper ships without databind and @DynamoDBTypeConvertedJson uses
the application's copy. The calls and configuration match the v1
converter exactly, so stored JSON stays the same.

When databind is missing, the mapper throws a DynamoDBMappingException
naming the dependency to add, when it builds the model for an annotated
class.

Add tests against v1's own converter, a test run with databind removed
from the classpath, and databind as a test-only dependency.
Check @DynamoDBTypeConvertedJson against JSON recorded from v1's
converter (aws-java-sdk-dynamodb 1.12.797 on jackson-databind 2.17.2)
over 145 cases. Writes must match byte for byte. Classes with
getter-only properties are compared without regard to property order,
because jackson-databind orders those by getDeclaredMethods(), which
differs between JVMs even in v1.
@RanVaknin
RanVaknin requested a review from a team as a code owner November 20, 2026 22:25
@RanVaknin
RanVaknin force-pushed the rvaknin/add-DynamoDBTypeConvertedJson-back branch from f9cd5c6 to e7322fe Compare November 20, 2026 22:25
@RanVaknin RanVaknin changed the title Add DynamoDBTypeConvertedJson annotation back, without relying on jackson-databind Add DynamoDBTypeConvertedJson annotation back, without relying on jackson-databind Nov 20, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant