garrytan/gstack · error · Error

Unknown page type: ${pageType}

Error message

Unknown page type: ${pageType}

What it means

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().

Source

Thrown at scripts/gstack-schema-pack.ts:279

export function getSchemaPackMutationPayload(): {
  schema_pack: SchemaPackJSON;
  schema_version: number;
} {
  return {
    schema_pack: GSTACK_CORE_SCHEMA_PACK,
    schema_version: 1, // gbrain mutation API version, not pack version
  };
}

/** Returns just the page type names. Used by tests + audit subcommand. */
export function getSchemaPackTypeNames(): ReadonlyArray<string> {
  return GSTACK_CORE_SCHEMA_PACK.page_types.map((t) => t.type);
}

/** Returns the retention policy for a given page type. Throws on unknown. */
export function getRetentionPolicy(pageType: string): SchemaTypeDefinition['retention'] {
  const def = GSTACK_CORE_SCHEMA_PACK.page_types.find((t) => t.type === pageType);
  if (!def) throw new Error(`Unknown page type: ${pageType}`);
  return def.retention;
}

View on GitHub (pinned to 94993f7401)

Solutions

  1. Source the page type from getSchemaPackTypeNames() rather than a hardcoded string
  2. If the type is intentionally new, add it to GSTACK_CORE_SCHEMA_PACK.page_types with a retention policy and bump schema_version
  3. Verify the pack version your code imports matches the runtime expectations

Example fix

// before
getRetentionPolicy('sessions')
// after
getRetentionPolicy('session')  // exact type name from the pack
Defensive patterns

Strategy: type-guard

Validate before calling

import { getSchemaPackTypeNames } from './gstack-schema-pack';
const KNOWN = new Set(getSchemaPackTypeNames());
if (!KNOWN.has(pageType)) {
  throw new Error(`Unsupported page type: ${pageType}. Valid: ${[...KNOWN].join(', ')}`);
}

Type guard

import { getSchemaPackTypeNames } from './gstack-schema-pack';
const isKnownPageType = (t: string): boolean => (getSchemaPackTypeNames() as readonly string[]).includes(t);

Prevention

When it happens

Trigger: 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.

Common situations: Schema pack version drift across gstack releases. Stale string constants in caller code. Forgetting to bump schema_version when adding a type.

Related errors


AI-assisted analysis of garrytan/gstack@94993f7401 (2026-08-12). Data as JSON: /api/errors/ed0032f4b34bd9ff. Report an issue: GitHub.