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.

[QUESTION] Should a warning be raised when some routes can never be called ?

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.
  • After submitting this, I commit to one of:
    • Read open issues with questions until I find 2 issues where I can help someone and add a comment to help there.
    • I already hit the “watch” button in this repository to receive notifications and I commit to help at least 2 people that ask questions in the future.
    • Implement a Pull Request for a confirmed bug.

Example

Here’s a self-contained, minimal, reproducible, example with my use case:

from fastapi import FastAPI

app = FastAPI()


@app.get("/user/{user}")
def read_user():
    return {"Hello": "World"}

@app.get("/user/me}")
def read_user_me():
   return {"Hello": "World": }

Description

According to https://fastapi.tiangolo.com/tutorial/path-params/?h=+order#order-matters the order of the routes matters. Ideally it’s a better practice to pay attention to the order, but one can sometimes make mistakes. In my example, the route /user/me will never be called.

It could maybe be interesting to raise a warning (or an Error?) to inform the user of this.

Environment

  • OS: Windows

  • FastAPI Version 0.60.0

  • Python version: 3.8

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
Tyrannascommented, Dec 16, 2020

Totally right ! Thx @ycd , closing the issue 😃

0reactions
tiangolocommented, Dec 27, 2020

Thanks for the help here @ycd ! 👏 🙇

Thanks for reporting back and closing the issue @Tyrannas 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Matched leaf route at location "/" does not have an element
Matched leaf route at location "/MyGames" does not have an element. This means it will render an <Outlet /> with a null value...
Read more >
SAMPLE – Written Warning for Attendance
The purpose of this letter is to emphasize the seriousness of your attendance record (absenteeism) as a. [classification] with the [agency/department name] ...
Read more >
988 Frequently Asked Questions - SAMHSA
FAQs About Call Routing, Privacy, Network Functioning · What will be in place to protect data privacy of users of 988? · Will...
Read more >
Emergency Exit Routes
Knowing the answers to these questions could keep you safe during an emergency. What is an exit route? An exit route is a...
Read more >
Disciplinary procedures | nidirect
Employers use disciplinary procedures to tell employees that their performance or conduct isn't up to the expected standard and to encourage improvement.
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