{"record":{"id":"e6d389f5c622a832","repo":"payloadcms/payload","slug":"either-collectionslug-globalslug-or-widgetslug-m","errorCode":null,"errorMessage":"Either collectionSlug, globalSlug, or widgetSlug must be provided","messagePattern":"Either collectionSlug, globalSlug, or widgetSlug must be provided","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/ui/src/utilities/buildFormState.ts","lineNumber":128,"sourceCode":"      i18n,\n      payload,\n      payload: { config },\n    },\n    returnLivePreviewURL,\n    returnLockStatus,\n    returnPreviewURL,\n    widgetSlug,\n    schemaPath = collectionSlug || globalSlug || widgetSlug,\n    select,\n    skipClientConfigAuth,\n    skipValidation,\n    updateLastEdited,\n  } = args\n\n  const selectMode = select ? getSelectMode(select) : undefined\n\n  if (!collectionSlug && !globalSlug && !widgetSlug) {\n    throw new Error('Either collectionSlug, globalSlug, or widgetSlug must be provided')\n  }\n\n  const schemaMap = getSchemaMap({\n    collectionSlug,\n    config,\n    globalSlug,\n    i18n,\n    widgetSlug,\n  })\n\n  const clientSchemaMap = getClientSchemaMap({\n    collectionSlug,\n    config: getClientConfig({\n      config,\n      i18n,\n      importMap: req.payload.importMap,\n      user: skipClientConfigAuth ? true : req.user,\n    }),","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/payloadcms/payload/blob/00c58b35c0ed348ddc22daabf467b139727214fd/packages/ui/src/utilities/buildFormState.ts#L110-L146","documentation":"A plain Error thrown by buildFormState when none of collectionSlug, globalSlug, or widgetSlug is supplied in the args. The function needs at least one entity identifier to locate the schema; absent all three it cannot proceed.","triggerScenarios":"buildFormState (or the form-state server function wrapping it) is called with an args object where collectionSlug, globalSlug, and widgetSlug are all undefined — e.g. a misconfigured form drawer, a widget invocation missing its slug, or a client RPC that omitted the entity.","commonSituations":"A custom form/drawer instantiated without passing the collection/global slug; a widget server function called without widgetSlug; refactoring that dropped the required prop; client-side state that conditionally sets the slug ending up undefined.","solutions":["Ensure the caller passes at least one of collectionSlug, globalSlug, or widgetSlug to buildFormState.","Add a client-side guard so the RPC is not issued when the slug is missing.","Check the form/drawer configuration that constructs the buildFormState args."],"exampleFix":"// before\nawait buildFormState({ schemaPath: undefined })\n\n// after\nif (!collectionSlug && !globalSlug && !widgetSlug) {\n  throw new Error('Cannot build form state: provide a collectionSlug, globalSlug, or widgetSlug')\n}\nawait buildFormState({ collectionSlug, schemaPath: collectionSlug })","handlingStrategy":"validation","validationCode":"function hasEntityIdentifier(args: { collectionSlug?: string; globalSlug?: string; widgetSlug?: string }): boolean {\n  return Boolean(args.collectionSlug || args.globalSlug || args.widgetSlug)\n}\n\nif (!hasEntityIdentifier({ collectionSlug, globalSlug, widgetSlug })) {\n  throw new Error('Provide a collectionSlug, globalSlug, or widgetSlug')\n}","typeGuard":"function isMissingEntityError(err: unknown): err is Error {\n  return err instanceof Error && /collectionSlug, globalSlug, or widgetSlug/i.test(err.message)\n}","tryCatchPattern":"try {\n  await buildFormState(args)\n} catch (err) {\n  if (isMissingEntityError(err)) {\n    // fix the caller to pass an entity identifier\n    return\n  }\n  throw err\n}","preventionTips":["Always pass at least one entity identifier when invoking buildFormState.","Add a client-side guard so the RPC is not issued with empty slugs.","Type the args so at least one slug is required (a discriminated union)."],"tags":["ui","form-state","validation","config"],"backgroundTag":null,"analyzedSha":"00c58b35c0ed348ddc22daabf467b139727214fd","analyzedAt":"2026-08-12T20:45:03.758Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}