Skip to content

Conversation

@Amogha-ark
Copy link
Contributor

@Amogha-ark Amogha-ark commented Jul 5, 2025

Add test coverage for multiple header values in TestClient

Summary

This PR adds test coverage for multiple header values passed as a list of tuples to FastAPI's TestClient, resolving a long-standing TODO comment in the test suite.

Background

The test file tests/test_tutorial/test_header_params/test_tutorial003.py contained a commented-out test case with a TODO comment questioning whether multiple header values were working correctly:

Technical Details

When multiple headers with the same name are passed as a list of tuples like [("x-token", "foo"), ("x-token", "bar")], FastAPI correctly processes them as a list of values ["foo", "bar"]. This is the expected HTTP behavior for multiple headers with the same name.

Type of Change:

  • Bug fix
  • Test coverage improvement
  • New feature
  • Breaking change
  • Documentation update

Checklist:

  • Tests pass locally
  • No breaking changes
  • Code follows project style guidelines
  • Self-review completed

@Amogha-ark
Copy link
Contributor Author

Hi, I see the PR is failing because of a missing label. I don’t have permission to add it — can someone from the team help with that? Thank you!”

@isgin01
Copy link

isgin01 commented Jul 5, 2025

This is the expected HTTP behavior for multiple headers with the same name.

Thanks for this PR. For reference, you might want to include relevant links next time https://www.rfc-editor.org/rfc/rfc9110.html#section-5.3-1

@Amogha-ark Amogha-ark changed the title ✨ Update test case for header parameters in test_tutorial003.py Update test case for header parameters in test_tutorial003.py Jul 6, 2025
@Amogha-ark Amogha-ark closed this Jul 6, 2025
@Amogha-ark Amogha-ark reopened this Jul 6, 2025
@Amogha-ark Amogha-ark changed the title Update test case for header parameters in test_tutorial003.py Add test case for header parameters in test_tutorial003.py Jul 6, 2025
@YuriiMotov YuriiMotov changed the title Add test case for header parameters in test_tutorial003.py ✅ Enable test case for duplicated headers in test_tutorial/test_header_params/test_tutorial003.py Jul 6, 2025
Copy link
Member

@YuriiMotov YuriiMotov left a comment

Choose a reason for hiding this comment

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

This test case covers the use-case described in docs: Duplicate headers.

Don't see anything wrong in enabling it

Copy link
Member

@tiangolo tiangolo left a comment

Choose a reason for hiding this comment

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

This was probably failing at some point 🤔 Thanks! ☕

@tiangolo tiangolo merged commit 5fef4d1 into fastapi:master Sep 20, 2025
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants