Skip to content

fix(nextjs): allow nextjs prerelease/preview versions to be deployed#665

Merged
annajowang merged 2 commits into
mainfrom
fix-nextjs-prerelease
Jul 8, 2026
Merged

fix(nextjs): allow nextjs prerelease/preview versions to be deployed#665
annajowang merged 2 commits into
mainfrom
fix-nextjs-prerelease

Conversation

@annajowang

Copy link
Copy Markdown
Collaborator

By passing { includePrerelease: true } to semver.satisfies, preview/prerelease builds like 16.3.0-preview will pass the vulnerability check. Real vulnerable canary versions will remain blocked.

Fixes #661
Fixes b/529799040

@wiz-9635d3485b

wiz-9635d3485b Bot commented Jul 8, 2026

Copy link
Copy Markdown

Wiz Scan Summary

Scanner Findings
Vulnerability Finding Vulnerabilities -
Data Finding Sensitive Data -
Secret Finding Secrets -
IaC Misconfiguration IaC Misconfigurations -
SAST Finding SAST Findings -
Software Management Finding Software Management Findings -
Total -

View scan details in Wiz

To detect these findings earlier in the dev lifecycle, try using Wiz Code VS Code Extension.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request wraps the build scripts for both the Angular and Next.js adapters with an 'isMain' check, updates Next.js version checking to support prerelease versions, adds a 'yaml' dependency, and introduces a new package verification script. Feedback highlights a critical issue where the 'isMain' utility will fail when executed via symlinks (common in 'node_modules/.bin/') because of path mismatches; resolving symlinks using 'fs.realpathSync' is recommended to fix this.

import { getBuildOptions, runBuild } from "@apphosting/common";

const opts = getBuildOptions();
if (isMain(import.meta)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The isMain utility function (imported from ../utils.js) currently checks process.argv[1] === fileURLToPath(meta.url). However, when this adapter is installed and executed via a symlink (which is the standard behavior for binaries in node_modules/.bin/), process.argv[1] will contain the symlink path, while import.meta.url resolves to the real path. This causes the comparison to evaluate to false, preventing the build command from executing.\n\nTo fix this, update the isMain implementation in packages/@apphosting/adapter-angular/src/utils.ts to resolve symlinks using fs.realpathSync (or fsExtra.realpathSync) before comparing:\n\ntypescript\nexport const isMain = (meta: ImportMeta) => {\n if (!meta) return false;\n if (!process.argv[1]) return false;\n try {\n return fsExtra.realpathSync(process.argv[1]) === fileURLToPath(meta.url);\n } catch {\n return false;\n }\n};\n


const root = process.cwd();
const opts = getBuildOptions();
if (isMain(import.meta)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The isMain utility function (imported from ../utils.js) currently checks process.argv[1] === fileURLToPath(meta.url). However, when this adapter is installed and executed via a symlink (which is the standard behavior for binaries in node_modules/.bin/), process.argv[1] will contain the symlink path, while import.meta.url resolves to the real path. This causes the comparison to evaluate to false, preventing the build command from executing.\n\nTo fix this, update the isMain implementation in packages/@apphosting/adapter-nextjs/src/utils.ts to resolve symlinks using fs.realpathSync (or fsExtra.realpathSync) before comparing:\n\ntypescript\nexport const isMain = (meta: ImportMeta): boolean => {\n if (!meta) return false;\n if (!process.argv[1]) return false;\n try {\n return fsExtra.realpathSync(process.argv[1]) === fileURLToPath(meta.url);\n } catch {\n return false;\n }\n};\n

@annajowang
annajowang force-pushed the fix-nextjs-prerelease branch from be2eacb to b1624ec Compare July 8, 2026 18:34
By passing { includePrerelease: true } to semver.satisfies, preview/prerelease builds like next@preview will pass the vulnerability check. Real vulnerable canary versions will remain blocked.

Fixes #661
Fixes b/529799040
@annajowang
annajowang force-pushed the fix-nextjs-prerelease branch from b1624ec to 8ce7405 Compare July 8, 2026 19:19
@annajowang

Copy link
Copy Markdown
Collaborator Author

/gemini

@annajowang
annajowang requested review from falahat, sjjj986 and taeold and removed request for abhis3, falahat, sjjj986 and taeold July 8, 2026 19:22
@annajowang

Copy link
Copy Markdown
Collaborator Author

@gemini-code-assist review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the Next.js version validation to include prerelease versions when checking against safe versions, adding a test case for a preview version. However, the reviewer noted that enabling { includePrerelease: true } introduces a critical security bypass by allowing vulnerable canary/prerelease versions to bypass the deployment block. The reviewer provided a safer alternative to handle prerelease versions and suggested adding test cases to ensure vulnerable canary versions are correctly blocked.

Comment thread packages/@apphosting/adapter-nextjs/src/utils.ts Outdated
Comment thread packages/@apphosting/adapter-nextjs/src/utils.spec.ts
@annajowang
annajowang merged commit 9e76881 into main Jul 8, 2026
19 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

checkNextJSVersion blocks Next.js preview/prerelease tags (e.g. next@preview)

2 participants