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.

Two functions with one path produce inconsistent results

See original GitHub issue

First Check

  • I added a very descriptive title to this issue.
  • I used the GitHub search to find a similar issue and didn’t find it.
  • I searched the FastAPI documentation, with the integrated search.
  • I already searched in Google “How to X in FastAPI” and didn’t find any information.
  • I already read and followed all the tutorial in the docs and didn’t find an answer.
  • I already checked if it is not related to FastAPI but to Pydantic.
  • I already checked if it is not related to FastAPI but to Swagger UI.
  • I already checked if it is not related to FastAPI but to ReDoc.

Commit to Help

  • I commit to help with one of those options 👆

Example Code

from fastapi import FastAPI

app = FastAPI()


@api.get("/foo")
async def foo1() -> dict:
    """Foo #1"""
    return {"content": "First foo"}


@api.get("/foo")
async def foo2() -> dict:
    """Foo #2"""
    return {"content": "Second foo"}

Description

  • GET /openapi.json (and consequently Swagger/Redoc) refer to /foo with Foo #2 documentation.
  • GET /foo returns First foo.
  • Expected GET /foo to return Second foo or GET /openapi.json to return Foo #1 documentation. As it stands, the results of overriding a path are inconsistent.

Operating System

Linux

Operating System Details

Debian 11.5

FastAPI Version

0.85.1

Python Version

3.10.8

Additional Context

As for prior art, searching wider brings up https://stackoverflow.com/questions/72219039/how-to-overwrite-extend-fastapi-apirouter-route, though this doesn’t address the inconsistency found.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
tiangolocommented, Nov 7, 2022

Cool, yeah, I would take a PR with that, if @bbeattie-phxlabs or @iudeen want to take a stab at that it would be great! 🚀

2reactions
iudeencommented, Nov 7, 2022

I think flask raises Exception. I’ll see if it’s worthy of a PR. May be I can give a try.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Inconsistent return types from python functions – Really?
I spent some time thinking about why python "allows" inconsistent return types and realized it is not just python, but pretty much any...
Read more >
FREE.INCONSISTENT - Klocwork Static Code Analysis
INCONSISTENT checker flags instances in which memory is accessed, either directly or through a series of dereference and field operations, and then freed...
Read more >
2.3: Incidence Graphs -Interpretations, Consistency, and ...
When two factors are connected by multiple signal paths, incoherence between the results of different paths leads to inconsistency.
Read more >
Inconsistent heuristics in theory and practice
A known problem with inconsistent heuristics is that they may cause algorithms like A∗ to find shorter paths to nodes.
Read more >
Use nested functions in a formula - Microsoft Support
Copy the example data in the following table, and paste it in cell A1 of a new Excel worksheet. For formulas to show...
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