Hmbown/CodeWhale · error · Error

message

Error message

message

What it means

fail() is a generic helper in gt-site.mjs that throws an Error with whatever message is passed. The bare "message" string here is the parameter name; every concrete validation failure in the site-generation checks (assertExactKeys, required stems, etc.) funnels through this thrower.

Solutions

  1. Read the full error output above the throw site to see which labeled assertion failed
  2. Ensure the generated dicts export exactly the expected keys (exportName/typeName table)
  3. Confirm REQUIRED_STEMS (chrome, home) are all present in the input data
  4. Update the expected-keys table in gt-site.mjs if the schema intentionally changed

Example fix

// before
// dict missing 'home' stem
// after
// regenerate data so chrome and home stems both exist, then rerun
node web/scripts/gt-site.mjs
Defensive patterns

Strategy: try-catch

Validate before calling

const EXPECTED = { computerUse: "ComputerUseDict" };
for (const stem of ["chrome", "home"]) {
  if (!(stem in data)) throw new Error(`missing stem: ${stem}`);
}
if (!data || typeof data !== "object" || Array.isArray(data)) throw new Error("data must be an object");

Type guard

function isPlainObject(v) {
  return v !== null && typeof v === "object" && !Array.isArray(v);
}

Try / catch

try {
  await generateSite();
} catch (e) {
  if (e instanceof Error && /must be an object|missing|REQUIRED/.test(e.message)) {
    console.error("Site data failed structural validation:", e.message);
  }
}

Prevention

When it happens

Trigger: Any structural validation failure during site generation: a dict/export missing expected keys, REQUIRED_STEMS (chrome, home) absent from generated data, or a value that is not a plain object where one is required.

Common situations: A generated dictionary file renamed or dropped an export (e.g. computerUse/ComputerUseDict missing), a new stem added without updating REQUIRED_STEMS, or a tool JSON schema drift.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@433685b202 (2026-09-15). Data as JSON: /api/errors/275ff2962d3006a8. Report an issue: GitHub.

Appendix: source

Thrown at web/scripts/gt-site.mjs:57

  "docs-fleet": { exportName: "docsFleet", typeName: "DocsFleetDict" },
  "docs-mcp": { exportName: "docsMcp", typeName: "DocsMcpDict" },
  "docs-modes": { exportName: "docsModes", typeName: "DocsModesDict" },
  "docs-runtime-api": { exportName: "docsRuntimeApi", typeName: "DocsRuntimeApiDict" },
  "docs-sandbox": { exportName: "docsSandbox", typeName: "DocsSandboxDict" },
  "docs-subagents": { exportName: "docsSubagents", typeName: "DocsSubagentsDict" },
  "docs-web": { exportName: "docsWeb", typeName: "DocsWebDict" },
  "docs-computers": { exportName: "docsComputers", typeName: "DocsComputersDict" },
  "docs-auth": { exportName: "docsAuth", typeName: "DocsAuthDict" },
  "docs-trust": { exportName: "docsTrust", typeName: "DocsTrustDict" },
  states: { exportName: "states", typeName: "StatesDict" },
  changelog: { exportName: "changelog", typeName: "ChangelogDict" },
  "computer-use": { exportName: "computerUse", typeName: "ComputerUseDict" },
};

const REQUIRED_STEMS = ["chrome", "home"];

function fail(message) {
  throw new Error(message);
}

function assertExactKeys(value, expected, label) {
  if (!value || typeof value !== "object" || Array.isArray(value)) {
    fail(`${label} must be an object`);
  }
  const actual = Object.keys(value).sort();
  const wanted = [...expected].sort();
  if (JSON.stringify(actual) !== JSON.stringify(wanted)) {
    fail(`${label} keys must be exactly: ${wanted.join(", ")} (found: ${actual.join(", ")})`);
  }
}

function stableStringify(value) {
  return `${JSON.stringify(value, null, 2)}\n`;
}

function deepEqual(left, right) {

View on GitHub (pinned to 433685b202)