fix(go): fix OAuth form URL encoding to respect custom MarshalJSON methods #11471
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.
Description
Fixes an issue with the Go SDK generator's OAuth client-credentials flow where form params were not being attached to the GetToken request.
The
newFormURLEncodedRequestBodyfunction was using reflection to extract struct fields based on json tags, but this missed fields likegrant_typethat are added via customMarshalJSONmethods (private fields with no json tag).Link to Devin run: https://app.devin.ai/sessions/8389b34fca664959a8935f69d4e1fd72
Requested by: @jsklan
Changes Made
newFormURLEncodedRequestBodyincaller.go_template to marshal the request to JSON first (respecting customMarshalJSONmethods), then convert to form URL encoded valuesversions.ymlwith changelog entries for v1.22.3 and v1.22.4oauth-client-credentialsandimdb:with-wiremock-testsseed fixture outputsUpdates Since Last Revision
--parallel 16, multiple wiremock containers were trying to bind to the same host port 8080docker-compose.test.ymlto use ephemeral ports ("0:8080"instead of"8080:8080")WireTestGenerator.tsto generate test code that readsWIREMOCK_PORTenv var with fallback to 8080seed.ymlscripts to discover the assigned port usingdocker compose port wiremock 8080and export it asWIREMOCK_PORTimdb:with-wiremock-tests,oauth-client-credentials)Testing
pnpm seed:local test --generator go-sdk --fixture oauth-client-credentials- passedpnpm seed:local test --generator go-sdk --fixture imdb:with-wiremock-tests- passedpnpm run check- lint checks passedReview Checklist
docker compose port wiremock 8080 | cut -d: -f2) works correctly in CI environmentWIREMOCK_PORTfallback to 8080 works for local development without docker