question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Header duplicate on subdependency

See original GitHub issue

Describe the bug Getting duplicate headers on API methods with subdependencies requiring the same dependency with a Header argument.

To Reproduce I’ve created an example repo to reproduce https://github.com/henriklindgren/fastapi-header-bug Steps to reproduce the behavior:

  1. Create an API-method which uses the same dependency, with a Header argument, in each of 2 paths of the dependency tree. Like this https://github.com/henriklindgren/fastapi-header-bug/blob/master/app/main.py
  2. Visit generated OpenApi json and see duplicate header requirements for the method.
"parameters": [
  {
    "required": true,
    "schema": {
      "title": "Someheader",
      "type": "string"
    },
    "name": "someheader",
    "in": "header"
  },
  {
    "required": true,
    "schema": {
      "title": "Someheader",
      "type": "string"
    },
    "name": "someheader",
    "in": "header"
  }
]

Expected behavior A single header requirement shown in the OpenApi definition.

Environment:

  • OS: Linux
  • FastAPI Version: 0.33.0
  • Python Version: 3.7.3

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
dmig-alarstudioscommented, Jun 1, 2020

@tiangolo could you please have a look at this?

1reaction
dmig-alarstudioscommented, May 19, 2020

I think the fix would be:

- response.headers.raw.extend(sub_response.headers.raw)
+ if response is not sub_response:
+   response.headers.raw.extend(sub_response.headers.raw)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Avoiding Circular Dependencies of header files - Stack Overflow
Some best practices I follow to avoid circular dependencies are,. Stick to OOAD principles. Don't include a header file, unless the class included...
Read more >
Top 10 C++ header file mistakes and how to fix them
Recommendation: Check your header filies by compiling them in isolation via a testMain.cpp that includes nothing but the header file under test.
Read more >
How to "state of the art" integrate multiple sub-modules with ...
If the logger library is header-only, the definitions will be implicitly inline (opt-out from ODR) and the linker will discard duplicates. – ...
Read more >
Consolidate Duplicate URLs with Canonical Tags
When a site has duplicate content, Google chooses the canonical URL. Learn more about canonical URLs and how to consolidate duplicate URLs.
Read more >
"should set Forwarded headers appropriately" router test fails o...
Bug 1802311 - Conformance: "should set Forwarded headers appropriately" ... Sub Component: ... Bug 1811862 has been marked as a duplicate of this...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found