Skip to content

ISSDK-692: Support text/plain JSON responses in Go SDK decode()#176

Open
sagadira wants to merge 1 commit into
CiscoM31:masterfrom
sagadira:ISSDK-692
Open

ISSDK-692: Support text/plain JSON responses in Go SDK decode()#176
sagadira wants to merge 1 commit into
CiscoM31:masterfrom
sagadira:ISSDK-692

Conversation

@sagadira

@sagadira sagadira commented Jun 9, 2026

Copy link
Copy Markdown

Note: This PR was scoped down to contain only the Go SDK fix. The CI/workflow infrastructure changes that were previously bundled here have been split out into PR #178 (JIRA ISSDK-1893).

Problem

When a gateway timeout occurs, Intersight returns Content-Type: text/plain; charset=utf-8 with a JSON-formatted error body (e.g. bullwinkle_gateway_timeout). The Go SDK decode() function only handled application/json and text/xml content types, hitting "undefined response type" for text/plain and 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 matched JsonCheck (application/json, text/json) and XmlCheck. A text/plain response — even with valid JSON body — fell through to the "undefined response type" error.

Fix

Added a fallback block in decode() (in client.mustache) that fires when:

  • contentType starts with text/plain, and
  • json.Valid(b) is true (body is well-formed JSON)

Includes full oneOf/anyOf schema support (same as the JsonCheck path).

Files Changed

File Change
modules/openapi-generator/src/main/resources/go/client.mustache Added text/plain JSON fallback in decode()
modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/GoClientCodegen.java Register client_test.mustache as a SupportingFile

Testing

Jenkins job test-is-go-ciscom31 on branch ISSDK-692Finished: SUCCESS
http://sam-tools01:8080/view/Fix-Jobs/job/Fix-Akhil/947

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.
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.

1 participant