fix: add max length validation to environment name#7087
Conversation
|
| Filename | Overview |
|---|---|
| backend/src/server/routes/v1/project-env-router.ts | Adds min(1).max(64) to the name field on both the create and update environment routes — correct and consistent with the existing slugSchema({ max: 64 }) constraint. |
Reviews (1): Last reviewed commit: "fix: add max length validation to enviro..." | Re-trigger Greptile
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e5d4c21cb1
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
adilsitos
left a comment
There was a problem hiding this comment.
Thanks for your contribution @Abdul-Moiz31! This is a nice addition, but we need to support longer strings, can you update it to be 255?
|
@adilsitos Sure will update in a min |
|
@adilsitos Updated |
adilsitos
left a comment
There was a problem hiding this comment.
I'll just wait the test finish and will merge it.
MubeenKodvavi
left a comment
There was a problem hiding this comment.
@Abdul-Moiz31 can you edit the PR description aswell that 255 char limit is utilised due to postgres VARCHAR field.
Also remove slug references. It is a seperate field and name constraints should not depend on it, as its uniqueness is ensured at API level. @adilsitos For extra safety, unique DB constraint for slug's references on project_environments table.
Context
Environment name field had no max length validation on the backend — only
z.string().trim()with no upper bound. The slug field correctly enforcedmax(64)viaslugSchema, but name was inconsistent.Submitting a name longer than 64 characters via the API bypassed all validation and would either store an unreasonably long string or produce a raw PostgreSQL 500 error at 255+ chars, instead of a proper 400 response.
Closes #7086
Screenshots
Before
After
Steps to verify the change
Type
Checklist
type(scope): short description(scope is optional, e.g.,fix: prevent crash on syncorfix(api): handle null response).