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.

Some endpoints only work with a trailing slash

See original GitHub issue

Bug Description

Some of our endpoints only work if they end with a trailing slash, i.e. /api/v1/organization/ works, but /api/v1/organization results in a 404

Steps to Reproduce

  1. Run nox -s api
  2. Try to navigate to localhost:8080/api/v1/organization, which will give a 404
  3. Navigate to localhost:8080/api/v1/organization/ which should work as expected

Expected behavior

For endpoints even without a trailing slash to work properly

Screenshots

If applicable, add screenshots to help explain your problem.

Environment

  • Version: main
  • OS: OSX
  • Python Version: 3.8
  • Docker Version: 20.10.14

Additional context

Note that /api/v1/health does work, so this is probably a problem with dynamically generating the endpoints.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
sanders41commented, May 23, 2022

The reason is the / in the root routes like here. as opposed to the no trailing / like in health.

Changing to no / like @router.get("", response_model=List[resource_model], name="List") makes localhost:8080/api/v1/organization work, but localhost:8080/api/v1/organization/ will no longer work.

I thought newer versions of FastAPI, including the version being used in fidesctl, were supposed to automatically handle this. I am not sure what that isn’t happening.

0reactions
ThomasLaPianacommented, Jul 7, 2022

I agree with the solution @TheAndrewJackson came up with, as I ended up at the exact same GitHub issue haha

I think the fidesops implementation is the right way to go 👍 🦖

Read more comments on GitHub >

github_iconTop Results From Across the Web

RESTful URI trailing slash or no trailing slash - Stack Overflow
Every URI (ending with slash or not) will point to a resource. As far as I know there is no specific recommendation to...
Read more >
Should You Have a Trailing Slash at the End of URLs? - Ahrefs
A trailing slash is a forward slash (“/”) placed at the end of a URL such as domain.com/ or domain.com/page/. But should you...
Read more >
Deprecate trailing slash match and change default value from ...
Whether to match to URLs irrespective of the presence of a trailing slash. If enabled a method mapped to "/users" also matches to...
Read more >
Using a Slash Character in Spring URLs - Baeldung
In this tutorial, we'll show some common solutions and recommendations for handling URLs with slashes in Spring. We'll also see why we shouldn't ......
Read more >
10.3. Routing — Fundamentals of Web Programming
The canonical URL for the projects endpoint has a trailing slash. It's similar to a folder in a file system. If you access...
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