Repository navigation
Support int64 and int32 in Marshal - #344
Closed
draarivpatel-ui wants to merge 1 commit into
Closed
draarivpatel-ui wants to merge 1 commit into
draarivpatel-ui wants to merge 1 commit into
Conversation
The encoder panicked with "invalid type: int64" for values typed int64 or int32, which occur in data deserialized by Kubernetes-aware JSON libraries (sigs.k8s.io/json uses int64 for integral numbers). Handle them like int in the type switch. Fixes itchyny#294
Owner
|
gojq does not support processing int64/int32. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
gojq.Marshalpanics withinvalid type: int64 (3)when the valuecontains integers typed
int64orint32. Such values are common whengojq is used as a library on data decoded by Kubernetes-aware JSON
libraries (
sigs.k8s.io/json.UnmarshalCaseSensitivePreserveIntsdecodes integral numbers as
int64, and even on 64-bit platformsintandint64are distinct Go types), so encoding results back toJSON crashes the process.
Fix
Handle
int64andint32in the encoder's type switch, exactly likethe existing
intcase, and extend the documented list of acceptedtypes accordingly.
A regression test covers plain and nested
int64/int32values; itpanics without the fix and passes with it. The full package test suite
passes.
Fixes #294