Commit 31671aa
authored
fix(vercel-api): normalize engines.node and drop nowConfig payload field (#364)
* docs(track): add fix-vercel-validation-20260430
Refs #359
* chore(track): start fix-vercel-validation-20260430 implementation
Refs #359
* fix(vercel-api): normalize engines.node to Vercel API enum
The Vercel REST API only accepts "24.x", "22.x", or "20.x" for
projectSettings.nodeVersion. v42.2.1 forwarded the raw `engines.node`
value verbatim, so consumers with semver ranges (">=24.0.0", "^20.0.0")
or exact versions ("24.0.0") hit 400 bad_request.
Add a local `normalizeNodeVersion` helper using `semver.intersects`
against a hardcoded list of supported Vercel majors. Map any matching
range to the canonical "NN.x" form. For unsupported inputs, omit the
field with a warning so the deployment falls back to the project default
instead of failing.
`semver` is promoted from a transitive dependency to a direct one, with
`@types/semver` for type support.
Refs #359
* fix(vercel-api): drop nowConfig from deployment payload
The Vercel REST API rejects nowConfig as an undeclared additional
property (HTTP 400). PR #350 attached it to DeploymentOptions based on
a misreading of the API contract; the Vercel CLI never sends it.
Mirror the CLI by copying a static whitelist of vercel.json keys —
buildCommand, installCommand, outputDirectory, framework, devCommand —
into projectSettings instead. Drop the nowConfig field from
ProjectConfig and the assignment in applyProjectConfig. Update tests
that asserted the broken behavior.
The static whitelist also makes the prior images / __proto__ /
constructor / prototype stripping unnecessary by construction.
Refs #359
* test(vercel-api): add #359 regression for semver-range engines.node
Combine both bugs into one scenario at unit and integration levels:
package.json with engines.node ">=24.0.0" plus vercel.json with
buildCommand. Assert the resulting payload normalizes nodeVersion to
"24.x", forwards buildCommand via projectSettings, and contains no
top-level nowConfig.
The integration test additionally tolerates known emulator network
errors but rejects any error message mentioning projectSettings.nodeVersion
or nowConfig — these would indicate the bugs have re-emerged.
Refs #359
* build: rebuild dist for #359 fixes
Bundles semver dependency, normalizeNodeVersion helper, and the
projectSettings whitelist replacing nowConfig.
Refs #359
* docs(track): mark fix-vercel-validation-20260430 tasks complete
Refs #359
* docs(track): note semver direct dep in tech-stack
Refs #359
* fix(vercel-api): match Vercel CLI highest-first node-version precedence
Reviewer caught divergence from `@vercel/build-utils.getSupportedNodeVersion`,
which iterates supported majors in descending order and returns the first
intersecting match. Flipping VERCEL_NODE_VERSIONS to ['24.x', '22.x', '20.x']
means `engines.node: '>=18'` now resolves to '24.x' (matching `vc deploy`)
instead of '20.x'.
Also clarify the unsupported-version warning to distinguish discontinued
majors (e.g. 18.x) from malformed input, and add an explicit test for the
discontinued-major case.
Refs #359
* chore(track): finalize fix-vercel-validation-20260430
Refs #359, PR #364
* chore: apply AI code review suggestions
Apply suggestions from cubic, gemini, and copilot review threads on
PR #364:
- Use `Object.hasOwn(vercelJson, key)` instead of `key in vercelJson`
so prototype-chain properties cannot leak into projectSettings even if
upstream code mutates Object.prototype (cubic, copilot).
- Type-guard whitelisted vercel.json values: only string and null pass
through to projectSettings. Other types surface a local warning
instead of producing a 400 from the Vercel API (gemini).
Add tests for both behaviors: explicit null sentinel preservation and
rejection of non-string/non-null values.
Refs #359, PR #3641 parent 4b001a4 commit 31671aa
17 files changed
Lines changed: 3587 additions & 83 deletions
File tree
- .please/docs
- knowledge
- tracks/completed/fix-vercel-validation-20260430
- dist
- src
- __integration__
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
Lines changed: 166 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
0 commit comments