Skip to content

ClientRegistration is missing on reflect-config.json #386

Open

Description

@fabionb

Describe the bug

I'm using spring boot native and I'm getting an HTTP 400 error on /api/client/register:

POST /api/client/register HTTP/1.1
Accept: application/json
Content-Type: application/json
UNLEASH-APPNAME: xpto-reader
X-UNLEASH-APPNAME: xpto-reader
UNLEASH-INSTANCEID: xpto
X-UNLEASH-CONNECTION-ID: 288de440-48ba-4759-afc2-3f983ace64fd
X-UNLEASH-SDK: unleash-client-java:9.3.2
User-Agent: xpto-reader
Unleash-Client-Spec: 5.1.5
Cache-Control: no-cache
Pragma: no-cache
Host: localhost:4242
Connection: keep-alive
Content-Length: 2

{}

HTTP/1.1 400 Bad Request
Content-Type: application/json; charset=utf-8
Content-Length: 338
ETag: W/"152-ohDoS0QSWDVe++vcJVvLFMVx30U"
Vary: Accept-Encoding
Date: Tue, 01 Sep 2026 19:00:45 GMT
Connection: keep-alive
Keep-Alive: timeout=15

{"id":"eeb43217-6414-46e2-9d39-b3e6e609da1f","name":"BadDataError","message":"Request validation failed: your request body or params contain invalid data. Refer to the `details` list for more information.","details":[{"path":"/body/appName","message":"The `/body/appName` property is required. It was not present on the data you sent."}]}

Steps to reproduce the bug

Build a spring boot native application. As soon as the app starts, the endpoint is called and a 400 is returned.

Expected behavior

Register client returning 200

Logs, error output, etc.

Screenshots

No response

Additional context

No response

Unleash version

6.10.1

Subscription type

Open source

Hosting type

Self-hosted

SDK information (language and version)

java 9.3.2

Activity

  1. fabionb commented on Sep 1, 2026

    @fabionb
    Author

    Maybe ClientMetrics have the same problem.

  2. moved this from New to Investigating in Issues and PRson Sep 2, 2026
  3. gastonfournier commented on Sep 2, 2026

    @gastonfournier
    Contributor

    Thanks @fabionb for the detailed report. The important detail here is that the request body is {}. This looks like a native-image serialization issue rather than a problem with the configured appName.

    Java SDK 9.3.2 does copy the configured application name into ClientRegistration, and the correct value in the request headers confirms that the configuration is available. However, ClientRegistration is not part of the reflection metadata bundled with that SDK version, that Gson uses to serialize objects. In a Spring Boot native executable, Gson cannot discover those fields in the same way it can on a regular JVM, so it serializes the registration as {}. The missing appName is then simply the first validation error reported by the server but the whole body shouldn't be an empty object.

    Your suggestion about ClientMetrics is probably correct because all outgoing requests follow the same Gson serialization path and that class is also absent from the bundled reflection metadata.

    Both versions are fairly old at this point: Java SDK 9.3.2 was released in January 2025, and Unleash Server 6.10.1 in June 2025. We recommend upgrading both where possible. That said, we checked the current code still has these classes absent from the reflection metadata, so upgrading the SDK alone would not fix this particular serialization problem. But if you want to contribute with a PR, we'll gladly accept it.

    We have previously accepted some best-effort native-image improvements, such as the initial reachability metadata (#267, #268), a native-image example (#332), and a targeted GraalVM-compatible HTTP change (#377, #378). However, native images have not been an officially supported target, and we do not have comprehensive native-image test coverage. We attempted to add a smoke test in #379, but closed it because it did not catch the problem it was meant to validate.

    As a possible workaround, you can add reflection metadata with declared-field access for:

    • io.getunleash.metric.ClientRegistration
    • io.getunleash.metric.ClientMetrics

    That should address the serialization path visible in this report, but we cannot guarantee that these are the only classes or runtime behaviors that need additional native-image configuration.

  4. fabionb commented on Sep 2, 2026

    @fabionb
    Author

    Hi @gastonfournier , thank you for your help.

    Yes, I solved it by registering these classes:

    import io.getunleash.metric.ClientMetrics
    import io.getunleash.metric.ClientRegistration
    
    ...
            hints.reflection().registerType(
                ClientMetrics::class.java,
                MemberCategory.DECLARED_FIELDS,
                MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
                MemberCategory.UNSAFE_ALLOCATED,
            )
            hints.reflection().registerType(
                ClientRegistration::class.java,
                MemberCategory.DECLARED_FIELDS,
                MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
                MemberCategory.UNSAFE_ALLOCATED,
            )
            hints.reflection().registerTypeIfPresent(
                classLoader,
                "io.getunleash.metric.MetricsBucket",
                MemberCategory.DECLARED_FIELDS,
                MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
                MemberCategory.UNSAFE_ALLOCATED,
            )
            hints.reflection().registerTypeIfPresent(
                classLoader,
                "io.getunleash.metric.ToggleCount",
                MemberCategory.DECLARED_FIELDS,
                MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
                MemberCategory.UNSAFE_ALLOCATED,
            )
    ...
    

    My suggestion is to add these classes into the file in unleash-java-sdk: https://github.com/Unleash/unleash-java-sdk/blob/unleash-client-java-9.3.2/src/main/resources/META-INF/native-image/io.getunleash/unleash-client-java/reflect-config.json since all other serialized classes that are registered here are working as expected. It seems to me that the unleash library forget to register it.

  5. fabionb commented on Sep 2, 2026

    @fabionb
    Author

    Regarding to upgrade the library: I'll do it as soon as possible, but the newer version probably will have the same problem.

  6. gastonfournier commented on Sep 9, 2026

    @gastonfournier
    Contributor

    My suggestion is to add these classes into the file in unleash-java-sdk: https://github.com/Unleash/unleash-java-sdk/blob/unleash-client-java-9.3.2/src/main/resources/META-INF/native-image/io.getunleash/unleash-client-java/reflect-config.json since all other serialized classes that are registered here are working as expected. It seems to me that the unleash library forget to register it.

    Hi @fabionb yes, this would be my suggestion as well, and maybe this was an oversight or just incremental build, somebody asked for the other classes and we just added the ones requested.

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

Metadata

Metadata

Labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions