Skip to content

ProblemDetails has custom MarshalJSON but no UnmarshalJSON — problem responses can't round-trip #18

Description

@rluders

`ProblemDetails.MarshalJSON` flattens `Extensions` to the top level per RFC 9457 (`type`/`title`/`status`/`detail`/`instance` plus arbitrary extension keys, all siblings). There's no corresponding `UnmarshalJSON`, so decoding a problem response back into a `ProblemDetails` loses every extension member — `json.Unmarshal` only populates the struct's declared fields and silently drops the rest, since `Extensions` isn't itself a tagged field that captures leftover keys.

This bites API clients and tests that need to decode a problem response and inspect an extension (e.g. a `messageKey` i18n hint, or a `correlationId`) — there's no way to get it back out via the type this library provides.

Requested: a matching `UnmarshalJSON` that reads the known fields and stuffs everything else into `Extensions`, so `ProblemDetails` round-trips through JSON.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions