question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CRD generator doesn't respect Jackson serialization/deserialization

See original GitHub issue

Describe the bug

Having a Java class that defines:

    private String myTest = null;

    public String getTest() {
        return myTest;
    }

generates a CRD with the following:

              myTest:
                type: string

But when trying to read a corresponding CR from Kubernetes fails with the following:

com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "myTest" , not marked as ignorable

Fabric8 Kubernetes Client version

5.10.1@latest

Steps to reproduce

Try to read a CR using the kubernetes-client where the Jackson serialization have a mismatch with the name of the fields.

The viable workaround is to annotate the field to respect the generate CRD name e.g.:

    @JsonProperty("myTest")
    private String myTest = null;

    public String getTest() {
        return myTest;
    }

Expected behavior

The generated CRD should respect the Jackson serialization/deserialization informations.

In general it should be possible to have a clean round-trip for arbitrary Java classes:

Java -> CRD -> CR in Kubernetes -> client reads the CR

Runtime

Kubernetes (vanilla), other (please specify in additional context)

Kubernetes API Server version

1.22.3@latest

Environment

Linux, other (please specify in additional context)

Fabric8 Kubernetes Client Logs

No response

Additional context

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
andreaTPcommented, Dec 23, 2021

It only creates one property. I agree that using JsonProperty annotation makes the intent much clearer.

I think that the available workaround make this issue pretty low in priority, I opened it mostly for tracking purposes.

I believe that we should somehow document what the generator takes in consideration (currently JsonProperty, JsonPropertyDescription and NotNull) so that we settle the right expectations.

0reactions
stale[bot]commented, Mar 24, 2022

This issue has been automatically marked as stale because it has not had any activity since 90 days. It will be closed if no further activity occurs within 7 days. Thank you for your contributions!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Deserialization doesn't seem to respect @JsonIgnore
Serialization works fine and ObjectList.json looks okay. When I try to read this file and deserialize I get the exception above. For some...
Read more >
InstantSerializer doesn't respect any format-related settings ...
InstantSerializer doesn't respect any of the following standard Jackson configuration settings: ObjectMapper#setDateFormat ...
Read more >
Map Serialization and Deserialization with Jackson - Baeldung
A quick and practical guide to serializing and deserializing Java Maps using Jackson.
Read more >
MessagePack: It's like JSON. but fast and small.
It's like JSON. but fast and small. MessagePack is an efficient binary serialization format. It lets you exchange data among multiple languages like...
Read more >
Java and JSON – Jackson Serialization with ObjectMapper
This guide contains examples that show you how to serialize and deserialize from Java to JSON. It covers the basics and the most...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found