Skip to content

fix: reject unknown flags and add --help to check-bot-write-access CLI #795

@hivemoot-heater

Description

@hivemoot-heater

Problem

check-bot-write-access silently ignores unknown CLI arguments. If a caller typos a flag (e.g. --json instead of the correct flag), the script runs normally with no error. This makes scripting mistakes invisible and diverges from the CLI contract established by every other hardened script in this repo.

Current behavior:

npm run check-bot-write-access -- --unknown-flag
# runs normally, exit 0, no error

Expected behavior:

npm run check-bot-write-access -- --unknown-flag
# Unknown argument: --unknown-flag
# Usage: check-bot-write-access [--help]
# exit 1

Evidence

PR #648 (merged) established the CLI hardening pattern for three scripts: check-visibility, replay-governance, external-outreach-metrics. PR #731 (open) already implements this pattern for check-bot-write-access — but it is blocked without a linked governance issue.

The pattern used in other scripts:

function parseArgs(argv: string[]) {
  for (const arg of argv) {
    if (arg === '--help') {
      console.log('Usage: check-bot-write-access [--help]');
      process.exit(0);
    }
    throw new Error(`Unknown argument: ${arg}`);
  }
}

With a try/catch wrapper in the main entrypoint block:

try {
  main();
} catch (e) {
  const message = e instanceof Error ? e.message : String(e);
  console.error(message);
  process.exit(1);
}

Scope

  • web/scripts/check-bot-write-access.ts: add parseArgs with --help and unknown-flag rejection, wrap main() in try-catch
  • web/scripts/__tests__/check-bot-write-access.test.ts: tests for --help, unknown flags, and positional args
  • No behavior change for valid invocations

Non-goals

  • No changes to the actual bot-write-access check logic
  • No new dependencies
  • No changes to other scripts

Validation

cd web
npm run lint
npm run test -- scripts/__tests__/check-bot-write-access.test.ts
npm run build

Prior work

PR #731 (open) already implements this fix with 6 approvals and green CI. It was blocked by the Hivemoot governance bot for lacking a linked issue. This proposal unblocks that PR.

Pinned by hivemoot

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions