Yeachan-Heo/oh-my-codex · error · Error

Refusing malformed ${field} in ${entryPath}.

Error message

Refusing malformed ${field} in ${entryPath}.

What it means

When an active_skills entry includes an active field, it must be a boolean. This error is thrown if active is present but has any other type (string "true", number 1, null). The strictness prevents truthy/falsy coercion bugs when cancellation logic toggles skill activation.

Source

Thrown at src/cli/index.ts:8340

  authority: ExactSessionCancellationAuthority,
  path: string,
): void {
  if (!Object.prototype.hasOwnProperty.call(value, "active_skills")) return;
  if (!Array.isArray(value.active_skills)) {
    throw new Error(`Refusing malformed active_skills in ${path}.`);
  }
  for (const [index, skill] of value.active_skills.entries()) {
    const entryPath = `${path} active_skills[${index}]`;
    if (!skill || typeof skill !== "object" || Array.isArray(skill)) {
      throw new Error(`Refusing malformed active_skills entry ${index} in ${path}.`);
    }
    const entry = skill as Record<string, unknown>;
    if (typeof entry.skill !== "string" || entry.skill.trim() === "") {
      throw new Error(`Refusing malformed skill in ${entryPath}.`);
    }
    for (const field of ["active"] as const) {
      if (Object.prototype.hasOwnProperty.call(entry, field) && typeof entry[field] !== "boolean") {
        throw new Error(`Refusing malformed ${field} in ${entryPath}.`);
      }
    }
    if (Object.prototype.hasOwnProperty.call(entry, "phase") && typeof entry.phase !== "string") {
      throw new Error(`Refusing malformed phase in ${entryPath}.`);
    }
    for (const [field, fieldValue] of Object.entries(entry)) {
      if (field.endsWith("_at") && typeof fieldValue !== "string") {
        throw new Error(`Refusing malformed ${field} in ${entryPath}.`);
      }
    }
    assertExactSkillOwner(entry, authority, entryPath);
  }
}

interface CancellationTestFaults {
  writeFailureMode?: string;
  rollbackFailureMode?: string;
}

View on GitHub (pinned to 3ad79a8a6f)

Solutions

  1. Find the entry in the state file and change active to a JSON boolean true or false
  2. Remove the active field if the default behavior is acceptable
  3. Retry the cancel command
  4. Keep booleans unquoted when editing state JSON by hand

Example fix

// before
{ "skill": "x", "active": "true" }
// after
{ "skill": "x", "active": true }
Defensive patterns

Strategy: type-guard

Validate before calling

function activeFlagsValid(entries: Record<string, unknown>[]): boolean {
  return entries.every((e) => !Object.prototype.hasOwnProperty.call(e, "active") || typeof e.active === "boolean");
}

Type guard

function isStrictBoolean(v: unknown): v is boolean {
  return typeof v === "boolean";
}

Prevention

When it happens

Trigger: A state entry like {"skill": "x", "active": "true"} or {"skill": "x", "active": 1}; the hasOwnProperty check passes but the typeof check fails, so cancel throws immediately.

Common situations: YAML-to-JSON conversion tools that stringify booleans; hand-edited state; other runtimes or serializers emitting 0/1 for booleans.

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 Yeachan-Heo/oh-my-codex@3ad79a8a6f (2026-08-27). Data as JSON: /api/errors/bb1b3470a5b8cd3d. Report an issue: GitHub.