Fix JSON marshal/unmarshal for types with integer:"string" tags#104
Open
c1-dev-bot[bot] wants to merge 1 commit into
Open
Fix JSON marshal/unmarshal for types with integer:"string" tags#104c1-dev-bot[bot] wants to merge 1 commit into
c1-dev-bot[bot] wants to merge 1 commit into
Conversation
17 struct types had fields with `integer:"string"` or `number:"string"` tags but were missing custom MarshalJSON/UnmarshalJSON methods. Without these, standard json.Marshal/Unmarshal doesn't understand the string-encoded integer format used by the API, causing errors like: "json: cannot unmarshal string into Go struct field ... of type int64" This also prevented users from round-tripping API response data through json.Marshal, as reported in IGA-719. Adds MarshalJSON/UnmarshalJSON delegating to utils.MarshalJSON/UnmarshalJSON for: AppResourceInput, AutomationExecutionRef, ExecuteAutomationResponse, FacetRange, Facets, FacetValue, FileField, Int64Field, Int64Rules, NumberField, PayloadWorkflowStep, RequestCatalogView, SearchAutomationExecutionsRequest, SFixed64Rules, SInt64Rules, TaskAuditErrorResult, WebhookSourceWorkflowStep. Includes regression tests for marshal round-trip behavior.
4 tasks
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.
Summary
Fixes IGA-719: Users could not
json.Marshaldata received from the API back to JSON.Root cause: 17 struct types in
pkg/models/shared/have fields withinteger:"string"tags (where the API serializes int64 values as JSON strings like"12345") but were missing customMarshalJSON/UnmarshalJSONmethods. Without these methods, Go's standardjsonpackage doesn't understand the string-encoded integer format, causing errors like:Fix: Added
MarshalJSON/UnmarshalJSONmethods delegating toutils.MarshalJSON/utils.UnmarshalJSONfor all 17 affected types:AppResourceInput,AutomationExecutionRef,ExecuteAutomationResponseFacetRange,Facets,FacetValue,FileFieldInt64Field,Int64Rules,NumberFieldPayloadWorkflowStep,RequestCatalogViewSearchAutomationExecutionsRequest,SFixed64Rules,SInt64RulesTaskAuditErrorResult,WebhookSourceWorkflowStepThis follows the same pattern as the temp fix in #97 (which added these methods to
Escalation), extended to all remaining types.Test plan
marshal_roundtrip_test.gowith regression tests covering JSON round-trip for affected typesgo test ./...)go build ./...)"