tinyhumansai/openhuman · error · Error

${label} must be a positive integer

Error message

${label} must be a positive integer

What it means

parsePositiveInt() guards the numeric flags of harness-subagent-rpc-audit (--rpc-timeout-ms, --spawn-wait-ms, --settle-wait-ms). Number(raw) must be an integer >= 1; zero, negatives, decimals, NaN (non-numeric strings) and Infinity all fail, with the flag's own name in the message.

Source

Thrown at scripts/debug/harness-subagent-rpc-audit.mjs:163

  ]);
  if (!scenarios.has(opts.scenario)) {
    throw new Error(
      `--scenario must be one of ${Array.from(scenarios).join(", ")}`,
    );
  }
  const providerModes = new Set(["direct-openai", "openhuman-backend"]);
  if (!providerModes.has(opts.providerMode)) {
    throw new Error(
      `--provider-mode must be one of ${Array.from(providerModes).join(", ")}`,
    );
  }
  return opts;
}

function parsePositiveInt(raw, label) {
  const value = Number(raw);
  if (!Number.isInteger(value) || value < 1) {
    throw new Error(`${label} must be a positive integer`);
  }
  return value;
}

function defaultOpenhumanDir() {
  return process.env.OPENHUMAN_APP_ENV === "staging"
    ? path.join(homedir(), ".openhuman-staging")
    : path.join(homedir(), ".openhuman");
}

async function defaultWorkspace() {
  if (process.env.OPENHUMAN_WORKSPACE) return process.env.OPENHUMAN_WORKSPACE;
  const openhumanDir = defaultOpenhumanDir();
  try {
    const active = await readFile(
      path.join(openhumanDir, "active_user.toml"),
      "utf8",
    );

View on GitHub (pinned to a221052e0d)

Solutions

  1. Pass a positive integer number of milliseconds, at least 1
  2. Strip units before passing (`10s` → `10000`)
  3. If the value is computed, default it in the caller: `WAIT=${WAIT:-120000}`

Example fix

# before
node scripts/debug/harness-subagent-rpc-audit.mjs --spawn-wait-ms 0

# after
node scripts/debug/harness-subagent-rpc-audit.mjs --spawn-wait-ms 120000
Defensive patterns

Strategy: validation

Validate before calling

function toPositiveIntMs(raw, label) {
  const n = Number(raw);
  if (!Number.isInteger(n) || n < 1) {
    console.error(`${label} must be a positive integer (ms)`); process.exit(2);
  }
  return n;
}

Type guard

function isPositiveInt(v) {
  const n = Number(v);
  return Number.isInteger(n) && n >= 1;
}

Prevention

When it happens

Trigger: `--spawn-wait-ms 0`, `--rpc-timeout-ms -1`, a float like `--settle-wait-ms 500.5`, a non-numeric string (`--rpc-timeout-ms 10s`), or an unquoted/empty shell expansion that yields an empty string.

Common situations: Unit confusion (passing seconds where ms is expected and fat-fingering 0); scripting the call with computed values that can be empty or NaN on edge cases.

Related errors


AI-assisted analysis of tinyhumansai/openhuman@a221052e0d (2026-08-16). Data as JSON: /api/errors/3b76e16ffef0f899. Report an issue: GitHub.