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(gateway): handle invalid project names in ScopedUser #1396

Merged
merged 4 commits into from
Nov 20, 2023

Conversation

jonaro00
Copy link
Member

@jonaro00 jonaro00 commented Nov 16, 2023

Description of change

Fixes endpoints with ScopedUser that are called with an invalid project name. Returns proper project name error instead of panic. The error is also properly logged instead of a panic printout.

Bonus change: red 🟥

How has this been tested? (if applicable)

Before:

cs --name äö project status

Getting project status failed

If getting project status failed repeatedly, please check Shuttle status at https://status.shuttle.rs before contacting the team on the Discord server.
Error: 502 Bad Gateway
Message: response from gateway is invalid. Please create a ticket to report this

After:

cs --name äö project status
INFO: Targeting non-standard API: http://localhost:8001

Getting project status failed

If getting project status failed repeatedly, please check Shuttle status at https://status.shuttle.rs before contacting the team on the Discord server.
Error: 400 Bad Request
Message: Invalid project name. Project names must:
    1. only contain lowercase alphanumeric characters or dashes `-`.
    2. not start or end with a dash.
    3. not be empty.
    4. be shorter than 64 characters.
    5. not contain any profanities.
    6. not be a reserved word.

Both of these give 400 instead of no response:
curl -v -H 'Authorization: Bearer dh9z58jttoes3qvt' localhost:8001/projects/äö
curl -v -H 'Authorization: Bearer dh9z58jttoes3qvt' localhost:8001/projects/äö/services/äö

@jonaro00 jonaro00 changed the title Gateway scopeduser error fix(gateway): handle invalid project names in ScopedUser Nov 16, 2023
@oddgrd
Copy link
Contributor

oddgrd commented Nov 17, 2023

Thanks for the detailed PR description!

@jonaro00 jonaro00 merged commit e9ec21b into shuttle-hq:main Nov 20, 2023
33 checks passed
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.

3 participants