Skip to content

Fix JSON marshal/unmarshal for types with integer:"string" tags#104

Open
c1-dev-bot[bot] wants to merge 1 commit into
mainfrom
fix/marshal-json-integer-string-tags
Open

Fix JSON marshal/unmarshal for types with integer:"string" tags#104
c1-dev-bot[bot] wants to merge 1 commit into
mainfrom
fix/marshal-json-integer-string-tags

Conversation

@c1-dev-bot
Copy link
Copy Markdown

@c1-dev-bot c1-dev-bot Bot commented Mar 31, 2026

Summary

Fixes IGA-719: Users could not json.Marshal data received from the API back to JSON.

Root cause: 17 struct types in pkg/models/shared/ have fields with integer:"string" tags (where the API serializes int64 values as JSON strings like "12345") but were missing custom MarshalJSON/UnmarshalJSON methods. Without these methods, Go's standard json package doesn't understand the string-encoded integer format, causing errors like:

json: cannot unmarshal string into Go struct field FacetValue.count of type int64

Fix: Added MarshalJSON/UnmarshalJSON methods delegating to utils.MarshalJSON/utils.UnmarshalJSON for all 17 affected types:

  • AppResourceInput, AutomationExecutionRef, ExecuteAutomationResponse
  • FacetRange, Facets, FacetValue, FileField
  • Int64Field, Int64Rules, NumberField
  • PayloadWorkflowStep, RequestCatalogView
  • SearchAutomationExecutionsRequest, SFixed64Rules, SInt64Rules
  • TaskAuditErrorResult, WebhookSourceWorkflowStep

This follows the same pattern as the temp fix in #97 (which added these methods to Escalation), extended to all remaining types.

Test plan

  • Added marshal_roundtrip_test.go with regression tests covering JSON round-trip for affected types
  • All existing tests pass (go test ./...)
  • Build succeeds (go build ./...)"

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.
@linear
Copy link
Copy Markdown

linear Bot commented Mar 31, 2026

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants