Skip to content

Validate --header format at the CLI boundary - #3200

Merged
Kludex merged 3 commits into
mainfrom
validate-header-format
Oct 11, 2026
Merged

Kludex merged 3 commits into
mainfrom
validate-header-format

Conversation

@Kludex

@Kludex Kludex commented Oct 11, 2026 •

Copy link
Copy Markdown
Owner

Passing --header without a colon (e.g. --header X-Foo) crashed with ValueError: not enough values to unpack from inside Config.load(). It now fails with a usage error:

Error: Invalid value for '--header': Expected 'Name:Value' format, got 'X-Foo'.

The parsing moves to a click callback using str.partition, so main() receives list[tuple[str, str]] and the # type: ignore[misc] goes away.

Supersedes #2992.

AI Disclaimer

This PR was developed with the assistance of either Claude or Codex. I've reviewed and verified the changes.

View guided diff

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
πŸ“ Code Review βœ… Completed 2026-10-11T15:22:22.532140Z a0dbeef PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with πŸ‘€ while any review is running, comments if it has suggestions, and reacts with πŸ‘ once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Review in Change Stack β†’

No actionable comments were generated in the recent review. πŸŽ‰

ℹ️ Recent review info
βš™οΈ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b9791723-b689-448c-829f-4cea986a4e33

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between a382dad and 60be77c.


πŸ“’ Files selected for processing (2)
  • tests/test_cli.py
  • uvicorn/main.py

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.



πŸ“ Walkthrough

Walkthrough

The CLI parses each --header value into a name/value tuple. It rejects values without a colon or with an empty name. main passes parsed tuples directly to run.

Changes

CLI Header Parsing

Layer / File(s) Summary
Parse and pass CLI headers
uvicorn/main.py, tests/test_cli.py
The --header callback parses values into name/value tuples and rejects missing colons or empty names. main passes parsed tuples to run. Tests cover valid parsing and invalid values.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: matheuzgomes


Merge Risk: βšͺ Minimal Β· up to 60be7

Malformed --header values now produce a CLI usage error, while valid values retain the tuple format expected by uvicorn.run. No actionable merge risk remains.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
βœ… Passed checks (4 passed)
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: validating the --header format at the CLI boundary.
Description check Passed The description accurately explains the malformed-header failure, the new usage error, and the Click callback parsing change.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.

  • Fix all pre-merge checks with AI
✨ Finishing Touches πŸ’‘ 1
πŸ“ Generate docstrings πŸ’‘
  • Commit to this branch
  • Create a new PR




πŸ§ͺ Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

  • Autofix Β· Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❀️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

πŸ“– Docs preview: https://b53c44ac-uvicorn.marcelotryle.workers.dev

@codspeed

codspeed Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

⚠️ 29 benchmarks spent significant time in system calls

System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.

Measurement and system calls

βœ… 34 untouched benchmarks


Comparing validate-header-format (60be77c) with main (a382dad)

Open in CodSpeed

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

Comment thread uvicorn/main.py Resolved

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found across 2 files

View guided diff | Re-trigger cubic

@Kludex
Kludex merged commit 07bd5d4 into main Oct 11, 2026
28 checks passed
@Kludex
Kludex deleted the validate-header-format branch October 11, 2026 15:29

This branch was successfully deployed

1 active deployment
cloudflare β€” 60be77cc Deployed Oct 11, 2026 by Kludex via docs-preview #1315
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