Skip to content

Conversation

@yiran0427
Copy link

@yiran0427 yiran0427 commented Sep 24, 2025

Fixes #5105

@yiran0427 yiran0427 requested review from a team as code owners September 24, 2025 17:09
@netlify
Copy link

netlify bot commented Sep 24, 2025

Deploy Preview for docs-kargo-io ready!

Name Link
🔨 Latest commit 5fbc50f
🔍 Latest deploy log https://app.netlify.com/projects/docs-kargo-io/deploys/68d4271f5362cc0008f07b70
😎 Deploy Preview https://deploy-preview-5106.docs.kargo.io
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

…sponse body as string

Signed-off-by: Yiran Cao <yiran0427@gmail.com>
@krancour krancour added priority/low Low commitment from maintainers; progress is likely to be community-driven area/controller Affects the (main) controller kind/enhancement An entirely new feature labels Sep 26, 2025
Comment on lines +303 to +318
// Log the JSON parsing error but continue to provide bodyText
logging.LoggerFromContext(ctx).Debug(
"Failed to parse JSON response, continuing with bodyText only",
"error", err,
)
} else {
// Unmarshal into map[string]any or []any
switch parsedBody.(type) {
case map[string]any, []any:
env["response"].(map[string]any)["body"] = parsedBody // nolint: forcetypeassert
default:
logging.LoggerFromContext(ctx).Debug(
"Unexpected JSON type, continuing with bodyText only",
"type", fmt.Sprintf("%T", parsedBody),
)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't feel right. To have gotten to this chunk of code, the conditional on line +300 evaluated to true. The content type of the response was explicitly JSON or the response has already been determined to be valid JSON (regardless of what the content type said). i.e. If we're in this block of code, it's expected that the body will unmarshal correctly. If it doesn't we should be sticking with the original behavior of returning an error.

Copy link
Author

@yiran0427 yiran0427 Sep 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh i see. is it better if i add another case for contentType == 'application/json'. then return bodyText: string(bodyBytes) and empty body?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need to do anything except revert the changes to these lines.

I think the only change needed to this file is the one on line +296.

@krancour krancour added the hacktoberfest Issue is eligible for Hacktoberfest -- https://hacktoberfest.com/ label Sep 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/controller Affects the (main) controller hacktoberfest Issue is eligible for Hacktoberfest -- https://hacktoberfest.com/ kind/enhancement An entirely new feature priority/low Low commitment from maintainers; progress is likely to be community-driven

Projects

None yet

Development

Successfully merging this pull request may close these issues.

support http plain text response body

2 participants