From 257835569cd0580d0f9f8391af45c411eb9a898a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20Orb=C3=A1n?= Date: Sun, 6 Nov 2022 07:02:24 +0100 Subject: [PATCH] fix: correctly mention `generateStaticParams` in error (#42524) Fixes #42517 Not sure if it warrants a test case, but let me know if I should add one. ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have a helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have a helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm build && pnpm lint` - [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md) --- packages/next/build/utils.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/next/build/utils.ts b/packages/next/build/utils.ts index 489aea31fd68f10..51dc98dc76d0c21 100644 --- a/packages/next/build/utils.ts +++ b/packages/next/build/utils.ts @@ -828,6 +828,7 @@ export async function buildStaticPaths({ configFileName, locales, defaultLocale, + appDir, }: { page: string getStaticPaths?: GetStaticPaths @@ -835,6 +836,7 @@ export async function buildStaticPaths({ configFileName: string locales?: string[] defaultLocale?: string + appDir?: boolean }): Promise< Omit>, 'paths'> & { paths: string[] @@ -982,7 +984,9 @@ export async function buildStaticPaths({ throw new Error( `A required parameter (${validParamKey}) was not provided as ${ repeat ? 'an array' : 'a string' - } in getStaticPaths for ${page}` + } in ${ + appDir ? 'generateStaticParams' : 'getStaticPaths' + } for ${page}` ) } let replaced = `[${repeat ? '...' : ''}${validParamKey}]` @@ -1193,6 +1197,7 @@ export async function buildAppStaticPaths({ }, page, configFileName, + appDir: true, }) } }