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

fix: prevent chainlit sub app to default all endpoints #1825

Merged
merged 5 commits into from
Jan 30, 2025
Merged

Conversation

willydouhard
Copy link
Collaborator

Fixing #1819

@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. backend Pertains to the Python backend. bug Something isn't working labels Jan 29, 2025
Copy link
Collaborator

@dokterbob dokterbob left a comment

Choose a reason for hiding this comment

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

It's a good start but I think we need a more rigorous solution: we should not have to refer to root_path or such things anywhere in our code, but rather move to use of request.url_for(). That way our code becomes less error prone and less sensitive to (the many) edge cases in HTTP routing.

References:

Regression unit tests

In addition, I would like to request we start writing unit tests for this -- I think https://github.com/Chainlit/chainlit/blob/main/backend/tests/test_server.py is the place.

I'm not 100% sure it's required but we could programmatically spin up a uvicorn. If we do, we can run uvicorn programmatically, e.g. in a pytest fixture using yield for teardown. Make sure to use a random port and check for availability.

backend/chainlit/server.py Outdated Show resolved Hide resolved
backend/chainlit/utils.py Show resolved Hide resolved
backend/chainlit/utils.py Show resolved Hide resolved
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Jan 29, 2025
@willydouhard willydouhard merged commit 2cf60b2 into main Jan 30, 2025
9 checks passed
@willydouhard willydouhard deleted the willy/1819 branch January 30, 2025 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Pertains to the Python backend. bug Something isn't working size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants