Unverified Commit 447d9cb1 authored by Jiwon Choi's avatar Jiwon Choi Committed by GitHub

Explain prerelease security upgrade limits (#99230)

Stacked on #99223.

### Why?

Stable security advisories can misclassify prerelease versions because
prerelease ordering does not reliably establish which security fixes
they contain. A blocked upgrade needs a clear way to continue on the
installed channel.

### How?

Explain the advisory limitation in the security error and give the full
`npx next@canary upgrade --ai=latest` command, with instructions to run
it from the app directory. Give unsupported Future Defaults requests the
same latest-channel recovery command.

<!-- NEXT_JS_LLM -->
parent 05e6bc87
...@@ -113,7 +113,7 @@ export async function getUpgradeAssessment( ...@@ -113,7 +113,7 @@ export async function getUpgradeAssessment(
reference: null, reference: null,
upgrade: { upgrade: {
status: 'blocked', status: 'blocked',
reason: `Security upgrades are not supported for ${channel} prereleases of Next.js. Use --ai=latest to upgrade ${channel === 'canary' ? 'on this channel' : 'to the latest stable release'}.`, reason: `The installed Next.js version (${installedVersion}) is a ${channel} prerelease. Security advisories target stable versions, and prereleases do not reliably follow stable version ordering, so an advisory could be a false positive. To upgrade to the latest ${channel === 'canary' ? 'canary' : 'stable'} release, run this command from the app's directory:\n\nnpx next@canary upgrade --ai=latest`,
}, },
} }
} }
...@@ -123,7 +123,7 @@ export async function getUpgradeAssessment( ...@@ -123,7 +123,7 @@ export async function getUpgradeAssessment(
reference: null, reference: null,
upgrade: { upgrade: {
status: 'blocked', status: 'blocked',
reason: `Future Defaults upgrades are not supported for Next.js ${installedVersion}. Use --ai=latest to upgrade to the latest stable release.`, reason: `Future Defaults upgrades are not supported for Next.js ${installedVersion}. To upgrade to the latest stable release, run this command from the app's directory:\n\nnpx next@canary upgrade --ai=latest`,
}, },
} }
} }
......
...@@ -166,11 +166,11 @@ describe('prepare latest upgrade', () => { ...@@ -166,11 +166,11 @@ describe('prepare latest upgrade', () => {
upgrade: { upgrade: {
status: 'blocked', status: 'blocked',
reason: reason:
'Security upgrades are not supported for canary prereleases of Next.js. Use --ai=latest to upgrade on this channel.', "The installed Next.js version (17.2.0-canary.4) is a canary prerelease. Security advisories target stable versions, and prereleases do not reliably follow stable version ordering, so an advisory could be a false positive. To upgrade to the latest canary release, run this command from the app's directory:\n\nnpx next@canary upgrade --ai=latest",
}, },
}) })
await expect(prepareUpgrade(directory, 'security')).rejects.toThrow( await expect(prepareUpgrade(directory, 'security')).rejects.toThrow(
'Security upgrades are not supported for canary prereleases of Next.js.' 'The installed Next.js version (17.2.0-canary.4) is a canary prerelease.'
) )
expect(global.fetch).toHaveBeenCalledTimes(0) expect(global.fetch).toHaveBeenCalledTimes(0)
}) })
...@@ -386,14 +386,16 @@ describe('prepare latest upgrade', () => { ...@@ -386,14 +386,16 @@ describe('prepare latest upgrade', () => {
const directory = await createApp(version) const directory = await createApp(version)
global.fetch = jest.fn() global.fetch = jest.fn()
await expect(prepareUpgrade(directory, 'security')).rejects.toThrow( await expect(prepareUpgrade(directory, 'security')).rejects.toThrow(
'Security upgrades are not supported for' `The installed Next.js version (${version}) is a`
) )
await expect(getUpgradeAssessment(version, 'security')).resolves.toEqual( await expect(getUpgradeAssessment(version, 'security')).resolves.toEqual(
expect.objectContaining({ expect.objectContaining({
affected: null, affected: null,
upgrade: expect.objectContaining({ upgrade: expect.objectContaining({
status: 'blocked', status: 'blocked',
reason: expect.stringContaining('Use --ai=latest'), reason: expect.stringContaining(
'npx next@canary upgrade --ai=latest'
),
}), }),
}) })
) )
...@@ -414,7 +416,9 @@ describe('prepare latest upgrade', () => { ...@@ -414,7 +416,9 @@ describe('prepare latest upgrade', () => {
affected: null, affected: null,
upgrade: expect.objectContaining({ upgrade: expect.objectContaining({
status: 'blocked', status: 'blocked',
reason: expect.stringContaining('Use --ai=latest'), reason: expect.stringContaining(
'npx next@canary upgrade --ai=latest'
),
}), }),
}) })
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment