Add missing MarshalJSON/UnmarshalJSON for integer:string models#101
Open
c1-dev-bot[bot] wants to merge 1 commit into
Open
Add missing MarshalJSON/UnmarshalJSON for integer:string models#101c1-dev-bot[bot] wants to merge 1 commit into
c1-dev-bot[bot] wants to merge 1 commit into
Conversation
…" 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.
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
MarshalJSON/UnmarshalJSONmethods to 17 model files that haveinteger:"string"struct tags but were missing the custom serialization methodsEscalationmodeljson.Marshal/json.Unmarshaldoes not process theinteger:"string"tag, so int64 fields serialized as quoted strings by the API (e.g."123") fail to unmarshal correctlyAffected Models
integer:"string"AppResourceInputgrantCountAutomationExecutionRefidExecuteAutomationResponseexecutionIdFacetRangecount,from,toFacetscountFacetValuecountFileFieldmaxFileSizeInt64FielddefaultValueInt64Rulesconst,gt,gte,lt,lte,in,notInNumberFieldmaxValue,minValue,stepPayloadWorkflowStepworkflowExecutionIdRequestCatalogViewmemberCountSearchAutomationExecutionsRequestexecutionIdSFixed64Rulesconst,gt,gte,lt,lte,in,notInSInt64Rulesconst,gt,gte,lt,lte,in,notInTaskAuditErrorResulterrorCountWebhookSourceWorkflowStepworkflowExecutionIdRoot Cause
The ConductorOne API serializes int64 fields as JSON strings (e.g.
"grantCount": "42"instead of"grantCount": 42). The SDK uses a custominteger:"string"struct tag to indicate this, and thepkg/utilspackage providesMarshalJSON/UnmarshalJSONfunctions that handle this tag. However, these utility functions are only invoked when a struct has customMarshalJSON/UnmarshalJSONmethods 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 ./...passesgo test ./...passesAutomated PR Notice
This PR was automatically created by c1-dev-bot as a potential implementation.
This code requires: