{"record":{"id":"ed0032f4b34bd9ff","repo":"garrytan/gstack","slug":"unknown-page-type-pagetype","errorCode":null,"errorMessage":"Unknown page type: ${pageType}","messagePattern":"Unknown page type: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/gstack-schema-pack.ts","lineNumber":279,"sourceCode":"export function getSchemaPackMutationPayload(): {\n  schema_pack: SchemaPackJSON;\n  schema_version: number;\n} {\n  return {\n    schema_pack: GSTACK_CORE_SCHEMA_PACK,\n    schema_version: 1, // gbrain mutation API version, not pack version\n  };\n}\n\n/** Returns just the page type names. Used by tests + audit subcommand. */\nexport function getSchemaPackTypeNames(): ReadonlyArray<string> {\n  return GSTACK_CORE_SCHEMA_PACK.page_types.map((t) => t.type);\n}\n\n/** Returns the retention policy for a given page type. Throws on unknown. */\nexport function getRetentionPolicy(pageType: string): SchemaTypeDefinition['retention'] {\n  const def = GSTACK_CORE_SCHEMA_PACK.page_types.find((t) => t.type === pageType);\n  if (!def) throw new Error(`Unknown page type: ${pageType}`);\n  return def.retention;\n}\n","sourceCodeStart":261,"sourceCodeEnd":282,"githubUrl":"https://github.com/garrytan/gstack/blob/94993f74012782fd94416dd44b8314f6363a13a4/scripts/gstack-schema-pack.ts#L261-L282","documentation":"getRetentionPolicy(pageType) in scripts/gstack-schema-pack.ts:279 looks up the page type in GSTACK_CORE_SCHEMA_PACK.page_types. If the type is not defined it throws. Used by tests and the audit subcommand; the canonical type names are exposed via getSchemaPackTypeNames().","triggerScenarios":"Calling getRetentionPolicy('unknown'). Issuing a mutation API call with a new page type before extending the schema pack. Hardcoded type string that drifted from the pack.","commonSituations":"Schema pack version drift across gstack releases. Stale string constants in caller code. Forgetting to bump schema_version when adding a type.","solutions":["Source the page type from getSchemaPackTypeNames() rather than a hardcoded string","If the type is intentionally new, add it to GSTACK_CORE_SCHEMA_PACK.page_types with a retention policy and bump schema_version","Verify the pack version your code imports matches the runtime expectations"],"exampleFix":"// before\ngetRetentionPolicy('sessions')\n// after\ngetRetentionPolicy('session')  // exact type name from the pack","handlingStrategy":"type-guard","validationCode":"import { getSchemaPackTypeNames } from './gstack-schema-pack';\nconst KNOWN = new Set(getSchemaPackTypeNames());\nif (!KNOWN.has(pageType)) {\n  throw new Error(`Unsupported page type: ${pageType}. Valid: ${[...KNOWN].join(', ')}`);\n}","typeGuard":"import { getSchemaPackTypeNames } from './gstack-schema-pack';\nconst isKnownPageType = (t: string): boolean => (getSchemaPackTypeNames() as readonly string[]).includes(t);","tryCatchPattern":null,"preventionTips":["Always source page types from getSchemaPackTypeNames() rather than literals","Bump schema_version when adding new page types","Pin the schema pack version in callers to detect drift"],"tags":["schema","gbrain","validation"],"backgroundTag":null,"analyzedSha":"94993f74012782fd94416dd44b8314f6363a13a4","analyzedAt":"2026-08-12T04:06:23.140Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}