ISSDK-692: Support text/plain JSON responses in Go SDK decode()#176
Open
sagadira wants to merge 1 commit into
Open
ISSDK-692: Support text/plain JSON responses in Go SDK decode()#176sagadira wants to merge 1 commit into
sagadira wants to merge 1 commit into
Conversation
Add fallback in decode() that checks if content-type starts with 'text/plain' AND body is valid JSON, then attempts JSON deserialization for oneOf/anyOf types. This handles scenarios where Intersight gateway timeouts return JSON bodies with text/plain content-type, which previously caused 'undefined response type' errors. Also regenerates all Go and C# samples to include this fix and CSCwu08056 fix.
4c63f24 to
10f5329
Compare
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.
Problem
When a gateway timeout occurs, Intersight returns
Content-Type: text/plain; charset=utf-8with a JSON-formatted error body (e.g.bullwinkle_gateway_timeout). The Go SDKdecode()function only handledapplication/jsonandtext/xmlcontent types, hitting"undefined response type"fortext/plainand failing to surface the error to the caller.Affected lines: https://github.com/CiscoDevNet/intersight-go/blob/main/client.go#L781 and #L833
Root Cause
decode()only matchedJsonCheck(application/json,text/json) andXmlCheck. Atext/plainresponse — even with valid JSON body — fell through to the"undefined response type"error.Fix
Added a fallback block in
decode()(inclient.mustache) that fires when:contentTypestarts withtext/plain, andjson.Valid(b)is true (body is well-formed JSON)Includes full oneOf/anyOf schema support (same as the
JsonCheckpath).Files Changed
modules/openapi-generator/src/main/resources/go/client.mustachetext/plainJSON fallback indecode()modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/GoClientCodegen.javaclient_test.mustacheas a SupportingFileTesting
Jenkins job
test-is-go-ciscom31on branchISSDK-692—Finished: SUCCESShttp://sam-tools01:8080/view/Fix-Jobs/job/Fix-Akhil/947