Skip to content

[]byte marshaled to null #272

Closed
Closed
@ash2k

Description

@ash2k

One of the fuzz tests in Kubernetes caught an issue:
This library:

{"metadata":{"selfLink":"Ǭ`/F苫ŽȢ噯榋C","resourceVersion":"4597642297830476577"},"items":[{"metadata":{"name":"玿j情1 蔝","generateName":"萀枦đ ","uid":".愥+ǽķ蓧u岏V","resourceVersion":"13323996552230461162","creationTimestamp":null},"data":{"輣 兀zʩL:Ģ梸ïĭ":"MŞFƤ趻Ă癆萃猷S幸4"},"binaryData":{"Ȟ櫤薯WDZĥȂ":null}}]}

encoding/json:

{"metadata":{"selfLink":"Ǭ`/F苫ŽȢ噯榋C","resourceVersion":"4597642297830476577"},"items":[{"metadata":{"name":"玿j情1 蔝","generateName":"萀枦đ ","uid":".愥+ǽķ蓧u岏V","resourceVersion":"13323996552230461162","creationTimestamp":null},"data":{"輣 兀zʩL:Ģ梸ïĭ":"MŞFƤ趻Ă癆萃猷S幸4"},"binaryData":{"Ȟ櫤薯WDZĥȂ":""}}]}

Notice how at the very end of the json the value in the map is not the same.
BinaryData field is declared like this:

BinaryData map[string][]byte `json:"binaryData,omitempty"`

https://github.com/kubernetes/kubernetes/blob/8f20a815e5ef27d4d247e42bff90e42706397ca2/staging/src/k8s.io/api/core/v1/types.go#L4742

Trying to migrate all encoding/json uses to this library in this PR kubernetes/kubernetes#63284

This is using commit 2ddf6d7

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions