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 server linting issues #6399

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Fix server linting issues #6399

wants to merge 1 commit into from

Conversation

neubig
Copy link
Contributor

@neubig neubig commented Jan 21, 2025

This PR fixes several linting issues in the server code:

  • Fix bytes vs str return type in auth.py by properly decoding JWT token
  • Handle None client in middleware.py by skipping rate limiting for requests without client info
  • Fix return type mismatches in settings.py by using FastAPI exceptions instead of direct JSONResponse returns

All linting checks now pass for the server directory.

Part of #6397


To run this PR locally, use the following command:

docker run -it --rm   -p 3000:3000   -v /var/run/docker.sock:/var/run/docker.sock   --add-host host.docker.internal:host-gateway   -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:b60afd9-nikolaik   --name openhands-app-b60afd9   docker.all-hands.dev/all-hands-ai/openhands:b60afd9

- Fix bytes vs str return type in auth.py
- Handle None client in middleware.py
- Fix return type mismatches in settings.py
Comment on lines +78 to +79
if not request.client:
return True # Allow requests without client info
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not very sure if this is ideal behavior here, would it be better to raise an exception?

Copy link
Collaborator

Choose a reason for hiding this comment

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

It should be okay, but it might not matter because we're thinking to remove the rate limiting here

@neubig neubig marked this pull request as ready for review January 21, 2025 20:51
logger.warning(str(e))
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND,
detail='Settings not found',
Copy link
Collaborator

Choose a reason for hiding this comment

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

This assumes any ValueError must be the error you threw at L29, which might be true now, but can evolve quickly.

How about throwing an HTTPException at L29, and here you could do

    except HTTPException:
        raise

@neubig neubig self-assigned this Jan 23, 2025
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.

4 participants