Skip to content

Add missing MarshalJSON/UnmarshalJSON for integer:string models#101

Open
c1-dev-bot[bot] wants to merge 1 commit into
mainfrom
fix/add-missing-marshal-unmarshal-json
Open

Add missing MarshalJSON/UnmarshalJSON for integer:string models#101
c1-dev-bot[bot] wants to merge 1 commit into
mainfrom
fix/add-missing-marshal-unmarshal-json

Conversation

@c1-dev-bot
Copy link
Copy Markdown

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

Summary

  • Adds custom MarshalJSON/UnmarshalJSON methods to 17 model files that have integer:"string" struct tags but were missing the custom serialization methods
  • Follows the same fix pattern applied in PR temp fix for unmarsheling issue #97 for the Escalation model
  • Without these methods, Go's standard json.Marshal/json.Unmarshal does not process the integer:"string" tag, so int64 fields serialized as quoted strings by the API (e.g. "123") fail to unmarshal correctly

Affected Models

File Fields with integer:"string"
AppResourceInput grantCount
AutomationExecutionRef id
ExecuteAutomationResponse executionId
FacetRange count, from, to
Facets count
FacetValue count
FileField maxFileSize
Int64Field defaultValue
Int64Rules const, gt, gte, lt, lte, in, notIn
NumberField maxValue, minValue, step
PayloadWorkflowStep workflowExecutionId
RequestCatalogView memberCount
SearchAutomationExecutionsRequest executionId
SFixed64Rules const, gt, gte, lt, lte, in, notIn
SInt64Rules const, gt, gte, lt, lte, in, notIn
TaskAuditErrorResult errorCount
WebhookSourceWorkflowStep workflowExecutionId

Root Cause

The ConductorOne API serializes int64 fields as JSON strings (e.g. "grantCount": "42" instead of "grantCount": 42). The SDK uses a custom integer:"string" struct tag to indicate this, and the pkg/utils package provides MarshalJSON/UnmarshalJSON functions that handle this tag. However, these utility functions are only invoked when a struct has custom MarshalJSON/UnmarshalJSON methods that delegate to them. Without these methods, Go's standard JSON encoder/decoder ignores the custom tag entirely, causing unmarshaling errors when it encounters a string where it expects a number.

Test plan

  • go build ./... passes
  • go test ./... passes
  • Manual testing with SDK operations that return/accept AppResourceInput, FacetRange, and other affected models

Automated PR Notice

This PR was automatically created by c1-dev-bot as a potential implementation.

This code requires:

  • Human review of the implementation approach
  • Manual testing to verify correctness
  • Approval from the appropriate team before merging

…" tags

PR #97 fixed the Escalation model's unmarshaling issue by adding custom
MarshalJSON/UnmarshalJSON methods that delegate to utils.MarshalJSON/
utils.UnmarshalJSON, which properly handle the `integer:"string"` struct
tag. However, 17 other model files have the same `integer:"string"` tag
but were missing these custom methods, causing the same unmarshaling
failures.

This commit adds the same MarshalJSON/UnmarshalJSON pattern to all
affected models:

- AppResourceInput (grantCount)
- AutomationExecutionRef (id)
- ExecuteAutomationResponse (executionId)
- FacetRange (count, from, to)
- Facets (count)
- FacetValue (count)
- FileField (maxFileSize)
- Int64Field (defaultValue)
- Int64Rules (const, gt, gte, lt, lte, in, notIn)
- NumberField (maxValue, minValue, step)
- PayloadWorkflowStep (workflowExecutionId)
- RequestCatalogView (memberCount)
- SearchAutomationExecutionsRequest (executionId)
- SFixed64Rules (const, gt, gte, lt, lte, in, notIn)
- SInt64Rules (const, gt, gte, lt, lte, in, notIn)
- TaskAuditErrorResult (errorCount)
- WebhookSourceWorkflowStep (workflowExecutionId)

Without these methods, Go's standard json.Marshal/json.Unmarshal does
not know about the `integer:"string"` tag, so int64 fields serialized
as quoted strings by the API (e.g. "123") fail to unmarshal correctly.
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