Validate Netlify deploy config - #641
Conversation
Greptile SummaryThis PR adds input validation to the Netlify deploy target, normalizing and rejecting blank
Confidence Score: 4/5Safe to merge with awareness that build still creates the output directory before validation runs — an issue flagged in a prior review that remains unaddressed. The ship path is correctly hardened: normalizedConfig fires at entry before any log, token fetch, or exec call. The build path still runs ctx.log and mkdir before renderPlan triggers validation, so a blank dir causes the output directory to be created on disk before the error is thrown — contradicting the PR's stated goal of rejecting invalid input before any side-effect work. packages/targets/deploy-netlify/src/index.ts — specifically the build function, which needs normalizedConfig called before the mkdir and ctx.log calls. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[build / ship called] --> B{which entry?}
B -->|ship| S1[normalizedConfig]
S1 -->|invalid| SE[throw Error]
S1 -->|valid| S2[log + dryRun check]
S2 -->|dryRun| S3[return dry-run result]
S2 -->|real deploy| S4[get NETLIFY_AUTH_TOKEN]
S4 --> S5[exec npx netlify-cli]
S5 --> S6[return]
B -->|build| B1[join planPath]
B1 --> B2[ctx.log side effect]
B2 --> B3[mkdir side effect]
B3 --> B4[renderPlan normalizedConfig]
B4 -->|invalid| BE[throw after mkdir ran]
B4 -->|valid| B5[writeFile plan]
B5 --> B6[return artifact]
style BE fill:#f88,stroke:#c00
style SE fill:#8f8,stroke:#080
Reviews (2): Last reviewed commit: "Validate Netlify deploy config" | Re-trigger Greptile |
|
|
||
| function optionalSiteId(value: string | undefined): string | undefined { | ||
| const id = optionalText(value, 'siteId'); | ||
| if (id && /[\\/?#\x00-\x1F\x7F]/.test(id)) { |
There was a problem hiding this comment.
The
siteId regex does not reject embedded spaces. A value like 'my site' trims cleanly, passes the regex, and is accepted as valid. It is a semantically invalid Netlify site ID that silently slips through the stated "single URL path segment" guard. Adding \s to the character class would close the gap.
| if (id && /[\\/?#\x00-\x1F\x7F]/.test(id)) { | |
| if (id && /[\s\\/?#\x00-\x1F\x7F]/.test(id)) { |
| @@ -26,6 +55,7 @@ function deployArgs(ctx: { channel: string; projectDir: string; version: string | |||
| } | |||
There was a problem hiding this comment.
Redundant
normalizedConfig calls in inner helpers
deployDir and deployArgs both call normalizedConfig internally, and both are called from renderPlan and ship after those callers have already normalized the config. This means normalizedConfig — and its validation logic — runs 3–4 times for a single ship or renderPlan invocation. While idempotent today, any future validator with observable side-effects (e.g., logging, counters) would fire multiple times unexpectedly. Consider removing the normalizedConfig calls from deployDir and deployArgs and relying solely on callers to normalize before calling these helpers.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
76f67e6 to
021e9ac
Compare
|
🤖 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 #640.
Changes:
Validation: