Validate Vercel deploy config - #639
Conversation
Greptile SummaryThis PR adds input validation to the Vercel deploy target, rejecting blank
Confidence Score: 3/5The validation logic is sound and the tests pass, but build() creates the output directory before the new guards run, leaving a silent side effect that contradicts the stated goal of the PR. The build() method calls mkdir() before renderPlan() triggers normalizedConfig(), so an invalid dir/project/org config still creates the output directory before the error is raised. This is exactly the scenario the PR set out to prevent, and ship() was fixed correctly but build() was missed. The slug regex also admits characters Vercel rejects, giving users false confidence that a name is valid when the CLI will still fail. packages/targets/deploy-vercel/src/index.ts — specifically the build() method and the optionalSlug regex. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[build / ship called] --> B{Entry point}
B -->|ship| C[normalizedConfig first]
B -->|build| D[ctx.log + mkdir runs first]
D --> E[renderPlan normalizedConfig]
C --> F{valid?}
E --> F
F -->|no| G[throw Error]
F -->|yes| H[normalized Config]
H --> I[deployArgs]
H --> J[deployDir]
I --> K[normalizedConfig again]
J --> L[normalizedConfig again]
I --> J
K --> M[build CLI args]
L --> N[resolve dir path]
M --> O[exec / dry-run return]
N --> O
|
| function optionalSlug(value: string | undefined, field: string): string | undefined { | ||
| const slug = optionalText(value, field); | ||
| if (slug && !/^[A-Za-z0-9._-]+$/.test(slug)) { | ||
| throw new Error(`deploy-vercel ${field} must contain only letters, numbers, dots, underscores, or hyphens`); | ||
| } | ||
| return slug; |
There was a problem hiding this comment.
Slug regex is more permissive than Vercel actually allows
The pattern /^[A-Za-z0-9._-]+$/ permits uppercase letters, dots, and underscores. Vercel project and org slugs are lowercase alphanumeric with hyphens only (no dots, no underscores, no uppercase). Passing a slug like My_Project.v2 will not be caught here, but the Vercel CLI will reject it at runtime. This won't cause silent data loss but does mean the local validation gives a false "clean" result for names that will ultimately fail.
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
11 similar comments
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
Fixes #638.
Changes:
Validation: