Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughSummary by CodeRabbit
WalkthroughAdds a gitignore rule for Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
tests/integration/commands/functions-serve/functions-serve.test.ts (1)
63-103:⚠️ Potential issue | 🟡 Minor"Default port" test no longer tests the default port — it's now a duplicate of the "custom port" test.
Both tests now pass
--port <getPort()>and fetch from that same port, so coverage of the default-port code path is lost. Either:
- Drop this test (redundant), or
- Keep it testing the default behavior — spawn without
--port, expect the server to listen on the documented default (9999), and skip/serialize it to avoid collisions.Given the PR's goal is concurrency safety, option 1 is probably the right call.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/integration/commands/functions-serve/functions-serve.test.ts` around lines 63 - 103, The "should serve functions on default port" test is now a duplicate of "should serve functions on custom port" because it passes --port; remove or revert it to test default behavior: either delete the entire test block named "should serve functions on default port" to avoid redundancy, or change the withFunctionsServer invocation in that test to not pass args/--port and assert the server listens on the documented default (9999) — if choosing the latter ensure you handle test isolation (skip or serialize) to avoid port collisions; locate the test by its title string and the use of withFunctionsServer/getPort to make the change.tests/integration/commands/dev/redirects.test.ts (1)
1-77:⚠️ Potential issue | 🟡 MinorFix Prettier failure before merging.
GitHub Actions reports a format issue in this file. The long
replace(...)call on line 52 is the likely offender — runnpm run format(orprettier --write) and commit.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/integration/commands/dev/redirects.test.ts` around lines 1 - 77, Prettier is failing due to a long line in the setup callback where the netlifyToml is written (the writeFile call that uses (await readFile(netlifyTomlPath, 'utf8')).replace(...)); fix by running the project formatter (npm run format or prettier --write tests/integration/commands/dev/redirects.test.ts) or manually reformat that expression (e.g., read the file into a variable, perform the replace on a separate line, then call writeFile) so the long replace(...) call is wrapped/split and the file passes Prettier; locate the offending code inside the setup callback referencing netlifyTomlPath and the writeFile call to apply the change.
🧹 Nitpick comments (1)
tests/integration/commands/completion/completion-install.test.ts (1)
26-26: Consider relaxingskipIfnow that--shell zshis explicit.Since the test now passes
--shell zshunconditionally, theSHELL !== '/bin/zsh'gate mostly filters on the developer's login shell rather than what the CLI actually exercises. This is fine to defer, but you may get broader CI coverage by either keeping the gate only where shell-specific filesystem behavior truly matters, or documenting that the gate exists because the post-install zsh-specific paths (e.g..zshrcedits) are what's under test.Also applies to: 49-49
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/integration/commands/completion/completion-install.test.ts` at line 26, The test currently wraps with test.skipIf(process.env.SHELL !== '/bin/zsh') while the test already passes --shell zsh explicitly; remove or relax that environment gate so the test runs regardless of the developer's login shell (or narrow the gate to only the specific assertions that depend on the real login shell). Locate the occurrences of test.skipIf(process.env.SHELL !== '/bin/zsh') (around the completion-install test and the other occurrence at the later block) and either delete the skipIf wrapper or replace it with a more targeted condition or comment explaining why it's needed for zsh-specific post-install path checks.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@tests/integration/commands/dev/redirects.test.ts`:
- Line 41: The env value for NETLIFY_DEV_SERVER_CHECK_SSG_ENDPOINTS is currently
a number; change it to a string to match NodeJS.ProcessEnv and existing tests
(use '1' instead of 1). Locate the devServer config object (devServer: { env: {
NETLIFY_DEV_SERVER_CHECK_SSG_ENDPOINTS: ... } }) in the test and update the
value to '1' so it matches the usage on line with
NETLIFY_DEV_SERVER_CHECK_SSG_ENDPOINTS: '1' and any strict equality checks
elsewhere.
- Around line 50-53: The current test uses a fragile literal string replace on
the netlify toml contents via readFile/netlifyTomlPath and writeFile which will
silently no-op if formatting changes; update the logic in the test to perform
the replacement with a regex (matching variations like whitespace around
`targetPort` and the value) or run the replace and then assert that the result
differs from the original (using targetPort.toString() as the new value), and if
no change occurred throw/assert a failure before calling writeFile so the test
fails loudly rather than leaving netlify.toml unchanged.
In `@tests/integration/framework-detection.test.ts`:
- Line 1: Prettier formatting failed due to an over-long single-line argument in
the integration test file; run the project's formatter (npm run format) and
commit the result so the import and long-arg test lines are wrapped correctly.
Specifically, format the file that imports execa and reflow any long single-line
args in the framework-detection tests into multiple lines or use array-style
args so Prettier passes; then stage and commit the formatted file.
---
Outside diff comments:
In `@tests/integration/commands/dev/redirects.test.ts`:
- Around line 1-77: Prettier is failing due to a long line in the setup callback
where the netlifyToml is written (the writeFile call that uses (await
readFile(netlifyTomlPath, 'utf8')).replace(...)); fix by running the project
formatter (npm run format or prettier --write
tests/integration/commands/dev/redirects.test.ts) or manually reformat that
expression (e.g., read the file into a variable, perform the replace on a
separate line, then call writeFile) so the long replace(...) call is
wrapped/split and the file passes Prettier; locate the offending code inside the
setup callback referencing netlifyTomlPath and the writeFile call to apply the
change.
In `@tests/integration/commands/functions-serve/functions-serve.test.ts`:
- Around line 63-103: The "should serve functions on default port" test is now a
duplicate of "should serve functions on custom port" because it passes --port;
remove or revert it to test default behavior: either delete the entire test
block named "should serve functions on default port" to avoid redundancy, or
change the withFunctionsServer invocation in that test to not pass args/--port
and assert the server listens on the documented default (9999) — if choosing the
latter ensure you handle test isolation (skip or serialize) to avoid port
collisions; locate the test by its title string and the use of
withFunctionsServer/getPort to make the change.
---
Nitpick comments:
In `@tests/integration/commands/completion/completion-install.test.ts`:
- Line 26: The test currently wraps with test.skipIf(process.env.SHELL !==
'/bin/zsh') while the test already passes --shell zsh explicitly; remove or
relax that environment gate so the test runs regardless of the developer's login
shell (or narrow the gate to only the specific assertions that depend on the
real login shell). Locate the occurrences of test.skipIf(process.env.SHELL !==
'/bin/zsh') (around the completion-install test and the other occurrence at the
later block) and either delete the skipIf wrapper or replace it with a more
targeted condition or comment explaining why it's needed for zsh-specific
post-install path checks.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f84e3d98-9abe-45ad-85b4-281c3a62eb61
⛔ Files ignored due to path filters (1)
tests/integration/commands/help/__snapshots__/help.test.ts.snapis excluded by!**/*.snap
📒 Files selected for processing (10)
.gitignoresrc/commands/completion/completion.tssrc/commands/completion/index.tssrc/utils/telemetry/report-error.tstests/integration/commands/completion/completion-install.test.tstests/integration/commands/dev/dev.test.tstests/integration/commands/dev/redirects.test.tstests/integration/commands/functions-serve/functions-serve.test.tstests/integration/framework-detection.test.tstests/unit/utils/copy-template-dir/copy-template-dir.test.ts
| await setupFixtureTests( | ||
| 'next-app', | ||
| { | ||
| devServer: { env: { NETLIFY_DEV_SERVER_CHECK_SSG_ENDPOINTS: 1 } }, |
There was a problem hiding this comment.
Env value should be a string for consistency and to match NodeJS.ProcessEnv typing.
Line 122 of this same file uses NETLIFY_DEV_SERVER_CHECK_SSG_ENDPOINTS: '1'. Node coerces numeric values at spawn time, but TS's ProcessEnv type expects strings and downstream code typically does strict equality against '1'.
- devServer: { env: { NETLIFY_DEV_SERVER_CHECK_SSG_ENDPOINTS: 1 } },
+ devServer: { env: { NETLIFY_DEV_SERVER_CHECK_SSG_ENDPOINTS: '1' } },📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| devServer: { env: { NETLIFY_DEV_SERVER_CHECK_SSG_ENDPOINTS: 1 } }, | |
| devServer: { env: { NETLIFY_DEV_SERVER_CHECK_SSG_ENDPOINTS: '1' } }, |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@tests/integration/commands/dev/redirects.test.ts` at line 41, The env value
for NETLIFY_DEV_SERVER_CHECK_SSG_ENDPOINTS is currently a number; change it to a
string to match NodeJS.ProcessEnv and existing tests (use '1' instead of 1).
Locate the devServer config object (devServer: { env: {
NETLIFY_DEV_SERVER_CHECK_SSG_ENDPOINTS: ... } }) in the test and update the
value to '1' so it matches the usage on line with
NETLIFY_DEV_SERVER_CHECK_SSG_ENDPOINTS: '1' and any strict equality checks
elsewhere.
| await writeFile( | ||
| netlifyTomlPath, | ||
| (await readFile(netlifyTomlPath, 'utf8')).replace('targetPort = 6123', `targetPort = ${targetPort.toString()}`), | ||
| ) |
There was a problem hiding this comment.
Fragile string replace — silently no-ops if targetPort = 6123 is ever reformatted.
String.prototype.replace with a literal needle returns the original string unchanged when no match is found, so a future reformat (e.g., targetPort=6123, different whitespace, or bumping the placeholder value) would leave netlify.toml pointing at the old port while next dev listens on the dynamic one — and the failure mode is a mysterious timeout rather than a clear error.
🛠️ Suggested fix: assert the replacement happened (or use a regex with a post-check)
- await writeFile(
- netlifyTomlPath,
- (await readFile(netlifyTomlPath, 'utf8')).replace('targetPort = 6123', `targetPort = ${targetPort.toString()}`),
- )
+ const originalToml = await readFile(netlifyTomlPath, 'utf8')
+ const updatedToml = originalToml.replace(/targetPort\s*=\s*\d+/, `targetPort = ${targetPort.toString()}`)
+ if (updatedToml === originalToml) {
+ throw new Error(`Failed to substitute targetPort in ${netlifyTomlPath}`)
+ }
+ await writeFile(netlifyTomlPath, updatedToml)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| await writeFile( | |
| netlifyTomlPath, | |
| (await readFile(netlifyTomlPath, 'utf8')).replace('targetPort = 6123', `targetPort = ${targetPort.toString()}`), | |
| ) | |
| const originalToml = await readFile(netlifyTomlPath, 'utf8') | |
| const updatedToml = originalToml.replace(/targetPort\s*=\s*\d+/, `targetPort = ${targetPort.toString()}`) | |
| if (updatedToml === originalToml) { | |
| throw new Error(`Failed to substitute targetPort in ${netlifyTomlPath}`) | |
| } | |
| await writeFile(netlifyTomlPath, updatedToml) |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@tests/integration/commands/dev/redirects.test.ts` around lines 50 - 53, The
current test uses a fragile literal string replace on the netlify toml contents
via readFile/netlifyTomlPath and writeFile which will silently no-op if
formatting changes; update the logic in the test to perform the replacement with
a regex (matching variations like whitespace around `targetPort` and the value)
or run the replace and then assert that the result differs from the original
(using targetPort.toString() as the new value), and if no change occurred
throw/assert a failure before calling writeFile so the test fails loudly rather
than leaving netlify.toml unchanged.
Replace hardcoded ports with dynamic getPort() calls across integration tests to prevent port collisions during concurrent test execution. Suppress telemetry error-reporting subprocesses when process.env.CI is set. Use dynamic port substitution for the next-app fixture in redirect tests. Fix test artifact leak in copy-template-dir tests with afterEach cleanup. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
59bd146 to
33a36d2
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (2)
tests/integration/commands/dev/redirects.test.ts (2)
41-41:⚠️ Potential issue | 🟡 MinorEnv value should be a string to match
NodeJS.ProcessEnv.
NETLIFY_DEV_SERVER_CHECK_SSG_ENDPOINTS: 1should be'1'— line 122 of this same file already uses the string form, and downstream checks typically compare strictly against'1'.- devServer: { env: { NETLIFY_DEV_SERVER_CHECK_SSG_ENDPOINTS: 1 } }, + devServer: { env: { NETLIFY_DEV_SERVER_CHECK_SSG_ENDPOINTS: '1' } },🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/integration/commands/dev/redirects.test.ts` at line 41, Change the env value for NETLIFY_DEV_SERVER_CHECK_SSG_ENDPOINTS from a number to a string where it is set in the devServer config; locate the devServer object that contains env: { NETLIFY_DEV_SERVER_CHECK_SSG_ENDPOINTS: 1 } and update the value to '1' so it matches NodeJS.ProcessEnv and the other usage in this test file.
50-53:⚠️ Potential issue | 🟡 MinorFragile literal-string replace in
netlify.tomlcan silently no-op.
String.prototype.replacewith a literal needle returns the original string when nothing matches. If the fixture'snetlify.tomlis ever reformatted (whitespace changes, value bump, etc.), this will silently leave the file untouched, the dev server will target6123whilenext devlistens ontargetPort, and tests will fail with a confusing timeout.🛠️ Suggested fix
- await writeFile( - netlifyTomlPath, - (await readFile(netlifyTomlPath, 'utf8')).replace('targetPort = 6123', `targetPort = ${targetPort.toString()}`), - ) + const originalToml = await readFile(netlifyTomlPath, 'utf8') + const updatedToml = originalToml.replace(/targetPort\s*=\s*\d+/, `targetPort = ${targetPort.toString()}`) + if (updatedToml === originalToml) { + throw new Error(`Failed to substitute targetPort in ${netlifyTomlPath}`) + } + await writeFile(netlifyTomlPath, updatedToml)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/integration/commands/dev/redirects.test.ts` around lines 50 - 53, The current literal-string replace on the netlify.toml contents is fragile; instead read the file with readFile(netlifyTomlPath, 'utf8'), perform a robust replacement of the targetPort value using a regex that matches "targetPort" with optional whitespace and an equals sign (e.g. /targetPort\s*=\s*\d+/) and replace it with `targetPort = ${targetPort}` so formatting changes won't cause a no-op, then write back with writeFile(netlifyTomlPath, updatedContents). Also assert that the replacement actually changed the file (throw or fail the test if not) so silent no-ops are caught.
🧹 Nitpick comments (2)
src/utils/telemetry/report-error.ts (1)
25-25: LGTM — aligns with existing CI-detection convention.The added
process.env.CIcheck matches the pattern already used insrc/utils/scripted-commands.ts(shouldForceFlagBeInjected,isInteractive). Note thatci-info'sisCIalready considersprocess.env.CIinternally, so the disjunction is effectively redundant, but keeping it consistent with the rest of the codebase is reasonable.One optional follow-up outside this file:
src/utils/telemetry/telemetry.tstrack()still guards onisCIalone. If the intent of this PR is to treatprocess.env.CIas authoritative for suppressing telemetry side effects in CI-like environments, consider aligningtrack()as well so telemetry behavior is consistent across both paths.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/utils/telemetry/report-error.ts` at line 25, The PR adds a process.env.CI check alongside isCI in report-error.ts to suppress telemetry in CI; update the telemetry gating to match by modifying the track() guard in the telemetry module to also check process.env.CI (i.e., ensure track() uses "isCI || process.env.CI") so telemetry suppression is consistent with the new check in report-error.ts while keeping existing isCI usage intact.tests/integration/commands/functions-serve/functions-serve.test.ts (1)
63-82: Test title no longer reflects behavior."should serve functions on default port" now passes an explicit
--portand is functionally identical to "should serve functions on custom port" on line 84. Consider renaming (or removing the duplicate) to avoid confusion — e.g. "should serve functions on the port provided via --port" or drop this test since it's now redundant with the next one.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/integration/commands/functions-serve/functions-serve.test.ts` around lines 63 - 82, The test title "should serve functions on default port" is misleading because the test passes an explicit --port; update the test case (the test(...) invocation in functions-serve.test.ts) to accurately reflect behavior by renaming it to something like "should serve functions on the port provided via --port" or remove this duplicate test entirely; locate the test block that calls getPort() and withFunctionsServer({ builder, args: ['--port', port.toString()], port }) and either change the first argument of test(...) to the new, descriptive title or delete the whole test block to avoid redundancy with the subsequent "should serve functions on custom port" test.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@tests/integration/commands/dev/redirects.test.ts`:
- Around line 38-77: Run Prettier (npm run format or prettier --write) on the
changed files to fix formatting issues flagged by CI; specifically reformat the
test file where the long one-liner occurs (in the setupFixtureTests block that
assigns packageJson.scripts.dev and the writeFile(netlifyTomlPath, (await
readFile(...)).replace(...)) call) so lines respect the repo printWidth, then
stage and commit the formatted file.
---
Duplicate comments:
In `@tests/integration/commands/dev/redirects.test.ts`:
- Line 41: Change the env value for NETLIFY_DEV_SERVER_CHECK_SSG_ENDPOINTS from
a number to a string where it is set in the devServer config; locate the
devServer object that contains env: { NETLIFY_DEV_SERVER_CHECK_SSG_ENDPOINTS: 1
} and update the value to '1' so it matches NodeJS.ProcessEnv and the other
usage in this test file.
- Around line 50-53: The current literal-string replace on the netlify.toml
contents is fragile; instead read the file with readFile(netlifyTomlPath,
'utf8'), perform a robust replacement of the targetPort value using a regex that
matches "targetPort" with optional whitespace and an equals sign (e.g.
/targetPort\s*=\s*\d+/) and replace it with `targetPort = ${targetPort}` so
formatting changes won't cause a no-op, then write back with
writeFile(netlifyTomlPath, updatedContents). Also assert that the replacement
actually changed the file (throw or fail the test if not) so silent no-ops are
caught.
---
Nitpick comments:
In `@src/utils/telemetry/report-error.ts`:
- Line 25: The PR adds a process.env.CI check alongside isCI in report-error.ts
to suppress telemetry in CI; update the telemetry gating to match by modifying
the track() guard in the telemetry module to also check process.env.CI (i.e.,
ensure track() uses "isCI || process.env.CI") so telemetry suppression is
consistent with the new check in report-error.ts while keeping existing isCI
usage intact.
In `@tests/integration/commands/functions-serve/functions-serve.test.ts`:
- Around line 63-82: The test title "should serve functions on default port" is
misleading because the test passes an explicit --port; update the test case (the
test(...) invocation in functions-serve.test.ts) to accurately reflect behavior
by renaming it to something like "should serve functions on the port provided
via --port" or remove this duplicate test entirely; locate the test block that
calls getPort() and withFunctionsServer({ builder, args: ['--port',
port.toString()], port }) and either change the first argument of test(...) to
the new, descriptive title or delete the whole test block to avoid redundancy
with the subsequent "should serve functions on custom port" test.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: a973665a-e06a-4027-abad-a95f092431b3
📒 Files selected for processing (7)
.gitignoresrc/utils/telemetry/report-error.tstests/integration/commands/dev/dev.test.tstests/integration/commands/dev/redirects.test.tstests/integration/commands/functions-serve/functions-serve.test.tstests/integration/framework-detection.test.tstests/unit/utils/copy-template-dir/copy-template-dir.test.ts
✅ Files skipped from review due to trivial changes (1)
- .gitignore
🚧 Files skipped from review as they are similar to previous changes (1)
- tests/integration/framework-detection.test.ts
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
getPort()calls across integration tests to prevent port collisions during concurrent executionprocess.env.CIis set (previously only checked theis-cipackage)next-appfixture in redirect testscopy-template-dirunit tests by moving cleanup toafterEachwithforce: truetests/unit/utils/tmpto.gitignoreas a safety netTest plan
copy-template-dirunit tests pass with no leaked artifacts🤖 Generated with Claude Code