这是indexloc提供的服务,不要输入任何密码
Skip to content

fix: content type bug introduced in #850 #854

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 2, 2025
Merged

Conversation

danielgtaylor
Copy link
Owner

This PR reverts part of #850 and adjusts the code so the tests for it still pass while maintaining the correct overall behavior for setting the content type.

Fixes #851

@Copilot Copilot AI review requested due to automatic review settings July 2, 2025 06:07
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR reverts part of #850 to restore correct content-type handling in error paths and updates tests accordingly.

  • Updated the test to expect application/problem+json for 406 errors
  • Moved header setting into writeResponse for both error and normal flows
  • Removed the final header set in transformAndWrite and adjusted logic in huma.go

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
huma_test.go Changed expected Content-Type from application/json to application/problem+json in the 406 response test
huma.go Added explicit ctx.SetHeader calls in both error and normal branches; removed the original footer header setting
Comments suppressed due to low confidence (1)

huma.go:498

  • The call to transformAndWrite here uses the hard-coded media type "application/json" rather than the computed ct variable. Consider passing ct to keep the marshaller in sync with the Content-Type header.
			if e := transformAndWrite(api, ctx, http.StatusNotAcceptable, "application/json", notAccept); e != nil {

Copy link

codecov bot commented Jul 2, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.56%. Comparing base (eafeecd) to head (0b3d165).
Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #854   +/-   ##
=======================================
  Coverage   92.55%   92.56%           
=======================================
  Files          23       23           
  Lines        5507     5511    +4     
=======================================
+ Hits         5097     5101    +4     
  Misses        351      351           
  Partials       59       59           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@danielgtaylor danielgtaylor merged commit df27bef into main Jul 2, 2025
7 checks passed
@danielgtaylor danielgtaylor deleted the partial-revert-850 branch July 2, 2025 06:10
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.

Huma no long returning default application/json header (re: most recent update v2.34)
1 participant