FasterXML / FasterXML/jackson-databind

Jackson 3 migration – polymorphic use case differences in `readerFor` and `writerFor` expected?

Open
#6,093 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
3.7k
Forks
1.5k
Avg merge
3d 6h
Merged PRs (30d)
28

Description

### Discussed in https://github.com/FasterXML/jackson-databind/discussions/6092

Originally posted by **soc** July 14, 2026
I have some code that makes use of various Jackson features including
- `@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type")`,
- `@JsonSubTypes({ @JsonSubTypes.Type(value = LinkSettings.Action.class, name = "action"), ... })`, and
- `@JsonTypeName`

to (de)serialize a `sealed interface LinkSettings` whose subtypes are records nested in that very interface as well as another sealed interface (`sealed interface Action`).

I have tests that serialize values of this type with

```
String serialized = jsonMapper.writerFor(LinkSettings.class).writeValueAsString(linkSettings);
```
working on Jackson 2.22.0.

When I migrate to Jackson 3.2.1, the serialization tests start failing, as the configured type name of the sealed interface appears to be ignored, and the type is traversed all to the bottom of the hierarchy (`record OpenWindow` being one the impls of `Action`):

```
expected: "action"
but was: "LinkSettings$Action$OpenWindow"
```

I was able to "fix" this by removing the `writerFor` call (that imo was already questionable before):

```
String serialized = jsonMapper.writeValueAsString(linkSettings)
```

Now I hit the same issue with deserialization, but there I cannot replace

```
jsonMapper.readerFor(LinkSettings.class).readValue(linkSettings);
```
with

```
jsonMapper.readValue(linkSettings);
```

Is this expected, or a symptom of a misconfiguration/misuse of annotations?
Or is this a bug and I should try to create a reproduction for it?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with discussion 6092 and the Jackson 3.2.1 behavior around writerFor(LinkSettings.class), readerFor(LinkSettings.class), and the shown sealed-interface annotations. Build a minimal reproduction from the LinkSettings hierarchy and compare typed versus untyped serialization and deserialization. Done means the expected handling of the configured type name is established, with a reproducible test if the behavior is a bug.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend-api-design
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.