Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crash if trying to set path to / #5003

Merged
merged 2 commits into from
Mar 19, 2024
Merged

crash if trying to set path to / #5003

merged 2 commits into from
Mar 19, 2024

Conversation

mifi
Copy link
Contributor

@mifi mifi commented Mar 17, 2024

fixes #4271

Copy link
Contributor

Diff output files
No diff

Copy link
Member

@Murderlon Murderlon left a comment

Choose a reason for hiding this comment

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

Why don't we allow this? I'd rather make this work as expected than let it crash.

@mifi
Copy link
Contributor Author

mifi commented Mar 19, 2024

This is just a quick fix, because if the user tries to set path to / it causes all kinds of hard to debug issues. I agree that rewriting all the code to accept a slash would be preferable but it needs deep changes in multiple files, changes which are hard to test/verify. I think it's a high risk change that could cause regressions so I don't think it's worth the risk for now. With this PR, at least it crashes early so that it's easy for the developer to know what's wrong, which IMO is much better than without it.

@Murderlon
Copy link
Member

I wonder how much effort that is, because I think it's the better improvement and doing this just sounds like we're never going to get back to it. It's very common for people to setup routers to "/" and I don't think that behaviour should be punished.

What do you think? Worth the effort?

@mifi
Copy link
Contributor Author

mifi commented Mar 19, 2024

i don't think the risk is worth the benefit of allowing /. maybe we can add a TODO about allowing it in the future, that way it doesn't sound like we're never going to get back to it?

@mifi mifi merged commit 4f2abc5 into main Mar 19, 2024
19 checks passed
@mifi mifi deleted the path-lone-slash branch March 19, 2024 10:34
@movy
Copy link

movy commented Mar 19, 2024

Folks, just to clarify from user's perspective: omitting path var is equivalent to setting up router on the root path. The issue is hidden somewhere where path is applied to the root locaiton, and if it's set to / it produces // which (surprisingly) throws whole routing in disarray. If path is unset, companion works from root location just fine.

@mifi
Copy link
Contributor Author

mifi commented Mar 19, 2024

Yes so i think this pr solves you problem, which is wasted time debugging, right?

@movy
Copy link

movy commented Mar 19, 2024

@mifi , the error message you added states 'server.path cannot be set to /' which is not what actually happens. Path is set to / when variable is unset.
I think a better message would be If you want to use '/' as server.path, leave 'path' variable unset.

@mifi mifi mentioned this pull request Mar 19, 2024
@mifi
Copy link
Contributor Author

mifi commented Mar 19, 2024

#5010

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

{ message: "Not Found" } when settings COMPANION_PATH="/"
3 participants