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

Conversation

@jh125486
Copy link
Contributor

PR for #843

  • Added NoFormatFallback field to Config to control format fallback.
  • Added positive and negative test for unknown/invalid Accept header (had to modify test harness for Config).
  • Fixed a bug(?) with how Content-Type was not set for 406 responses by moving setting of the Content-Type into the transformWrite().

- Added positive and negative test for unknown/invalid Accept header
- Fixed a bug(?) with how Content-Type was set for 406 responses by moving the Content-Type set into the `transformWrite()`
Copilot AI review requested due to automatic review settings June 25, 2025 00:52
Copy link
Contributor

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 introduces a new configuration flag, NoFormatFallback, to control behavior when a client requests an unknown Accept header, and fixes a bug where the Content-Type header was not set for 406 responses. Key changes include adding the NoFormatFallback field to Config, updating negotiation logic and default format assignment in api.go, and adding positive/negative tests in huma_test.go.

Reviewed Changes

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

File Description
huma_test.go Added new test cases for unknown Accept header handling
huma.go Moved setting of Content-Type header into transformAndWrite
api.go Updated negotiation and default format assignment with NoFormatFallback
Comments suppressed due to low confidence (1)

api.go:410

  • [nitpick] It may be helpful to add a brief comment clarifying why DefaultFormat is only automatically set when NoFormatFallback is false, as this behavior is central to the new feature.
	if config.DefaultFormat == "" && !config.NoFormatFallback {

@jh125486 jh125486 changed the title Allow 406 Not Acceptable with NoFormatFallback config feat: #843 Allow 406 Not Acceptable with NoFormatFallback config Jun 25, 2025
@codecov
Copy link

codecov bot commented Jun 25, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.55%. Comparing base (e5fa153) to head (12c60c3).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #850      +/-   ##
==========================================
+ Coverage   92.47%   92.55%   +0.08%     
==========================================
  Files          23       23              
  Lines        5501     5507       +6     
==========================================
+ Hits         5087     5097      +10     
+ Misses        354      351       -3     
+ Partials       60       59       -1     

☔ 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 eafeecd into danielgtaylor:main Jun 30, 2025
4 checks passed
danielgtaylor added a commit that referenced this pull request Jul 2, 2025
danielgtaylor added a commit that referenced this pull request Jul 2, 2025
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.

2 participants