openai/codex-plugin-cc · error · Error

Expected ${label} to be an object.

Error message

Expected ${label} to be an object.

What it means

Thrown by requireObject() when a value that must be a JSON object is instead null, undefined, a non-object, or an array. It is a structural validator used when mutating nested manifest fields (package-lock.json's packages[""], marketplace.json metadata, marketplace.json plugins[codex]). The label names exactly which field failed so the offending manifest is identifiable.

Source

Thrown at scripts/bump-version.mjs:130

      throw new Error(`Unexpected extra argument: ${arg}`);
    } else {
      options.version = arg;
    }
  }

  options.root = path.resolve(options.root);
  return options;
}

function validateVersion(version) {
  if (!VERSION_PATTERN.test(version)) {
    throw new Error(`Expected a semver-like version such as 1.0.3, got: ${version}`);
  }
}

function requireObject(value, label) {
  if (!value || typeof value !== "object" || Array.isArray(value)) {
    throw new Error(`Expected ${label} to be an object.`);
  }
}

function findMarketplacePlugin(json) {
  const plugin = json.plugins?.find((entry) => entry?.name === "codex");
  requireObject(plugin, ".claude-plugin/marketplace.json plugins[codex]");
  return plugin;
}

function readJson(root, file) {
  const filePath = path.join(root, file);
  return JSON.parse(fs.readFileSync(filePath, "utf8"));
}

function writeJson(root, file, json) {
  const filePath = path.join(root, file);
  fs.writeFileSync(filePath, `${JSON.stringify(json, null, 2)}\n`);
}

View on GitHub (pinned to db52e28f4d)

Solutions

  1. Inspect the manifest named in the error label and restore the missing object (e.g. add a `metadata: {}` block or a codex plugin entry).
  2. Regenerate package-lock.json with `npm install` to restore the packages[""] self-entry.
  3. Ensure marketplace.json has both `metadata` and a plugins[] entry with name 'codex' before bumping.
  4. Run from the correct repository root so all four target manifests are present.

Example fix

// before — .claude-plugin/marketplace.json
{ "plugins": [{ "name": "codex" }] } // no metadata

// after
{
  "metadata": { "version": "0.0.0" },
  "plugins": [{ "name": "codex", "version": "0.0.0" }]
}
Defensive patterns

Strategy: type-guard

Validate before calling

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

// pre-flight manifest shape before bumping:
const ml = readJson(root, ".claude-plugin/marketplace.json");
if (!isPlainObject(ml.metadata)) throw new Error("marketplace.json missing metadata object");
if (!ml.plugins?.some((p) => p?.name === "codex")) throw new Error("marketplace.json missing codex plugin");
const lock = readJson(root, "package-lock.json");
if (!isPlainObject(lock.packages?.[""])) throw new Error("package-lock.json missing packages[\"\"]");

Type guard

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

Try / catch

try {
  bumpVersion(root, version);
} catch (err) {
  if (/Expected .* to be an object/.test(err.message)) {
    console.error("Manifest structurally invalid:", err.message);
    // inspect/regenerate the named file before retrying
  } else throw err;
}

Prevention

When it happens

Trigger: Running bump-version against a repo whose package-lock.json lacks packages[""], or marketplace.json lacks metadata, or whose plugins array has no entry with name 'codex' (findMarketplacePlugin returns undefined → requireObject fails). Reached during the write (set) path of bumpVersion or checkVersions.

Common situations: Regenerated package-lock.json with a different shape (older/newer npm); hand-edited marketplace.json missing the metadata block; the codex plugin entry was renamed or removed; running against a subtree that doesn't contain the full marketplace manifest.

Related errors


AI-assisted analysis of openai/codex-plugin-cc@db52e28f4d (2026-08-13). Data as JSON: /api/errors/e0542e22b1c8dec8. Report an issue: GitHub.