Skip to content

Proposed work: harden source validation in live bounty checker scripts #1145

Description

@SueJianjian

Summary

scripts/check_bounty_issue_states.py and scripts/check_live_bounty_closing_refs.py each use a required mutually-exclusive --input/--repo source selection, but both still branch on string truthiness at runtime:

  • check_bounty_issue_states.py
    • data = _load_input(args.input) if args.input else load_live_data(args.repo, args.api_host)
    • if args.fix:
    • if args.input:
  • check_live_bounty_closing_refs.py
    • data = _load_input(args.input) if args.input else load_live_data(args.repo, args.api_host, args.state, args.pr)

That means empty-string or whitespace-only source values can satisfy argparse's required source group, then still select the wrong runtime path or defer validation until a raw traceback / gh error.

Why it is useful

These two scripts are public bounty hygiene checks used around live MergeWork issue/PR maintenance:

  • check_bounty_issue_states.py verifies that open public bounty rows still point at open GitHub issues, and can optionally --fix by reopening issues
  • check_live_bounty_closing_refs.py checks PR bodies for Closes #... / similar references against still-open bounty issues

Malformed source arguments in those tools should fail early and predictably with bounded CLI errors, not rely on implicit falsy-string branch selection.

This is a narrow, low-risk maintainability hardening slice that complements the earlier source-validation proposals without duplicating their scope.

Smallest useful scope

  • reject empty or whitespace-only --input values in both scripts with a clear argparse-facing error
  • reject empty or whitespace-only --repo values in both scripts before any gh invocation
  • choose fixture/live mode using explicit presence checks (is not None) after validation instead of string truthiness
  • preserve existing valid fixture mode, valid live mode, and valid --fix behavior

Acceptance criteria

  • scripts/check_bounty_issue_states.py rejects --input "", --input " ", and --repo " " with clear CLI validation and no Python traceback
  • scripts/check_bounty_issue_states.py --fix continues to require a valid live --repo source and does not accept malformed empty source values
  • scripts/check_live_bounty_closing_refs.py rejects --input "", --input " ", and --repo " " with clear CLI validation and no Python traceback
  • valid fixture mode still works for both scripts
  • valid live --repo owner/name mode still works for both scripts
  • focused tests cover invalid empty/whitespace source values and at least one valid branch per script

Evidence

Current main source still shows the unfixed truthiness pattern:

  • scripts/check_bounty_issue_states.py

    • required source group with source.add_argument("--input", ...) and source.add_argument("--repo", ...)
    • runtime selection: _load_input(args.input) if args.input else load_live_data(args.repo, args.api_host)
    • --fix gate still checks if args.input
  • scripts/check_live_bounty_closing_refs.py

    • required source group with source.add_argument("--input", ...) and source.add_argument("--repo", ...)
    • runtime selection: _load_input(args.input) if args.input else load_live_data(args.repo, args.api_host, args.state, args.pr)

These are the same narrow failure shape already recognized in adjacent scripts, but for a different pair of bounty-check helpers.

Duplicate search

Checked existing open proposed-work issues and related submissions around:

  • check_bounty_issue_states
  • check_live_bounty_closing_refs
  • source validation
  • empty --input
  • whitespace --repo

Related but distinct:

  • #801 covers scripts/review_bounty_candidates.py
  • #805 covers scripts/submission_quality_gate.py
  • #807 covers the remaining report-script slice: scripts/proposed_work_triage.py, scripts/claim_inventory.py, and scripts/pr_queue_health.py
  • #1104 covers wiring the closing-reference checker into PR readiness/CI, not its CLI source validation

I did not find an existing proposed-work issue specifically for source-argument hardening in check_bounty_issue_states.py and check_live_bounty_closing_refs.py.

Out of scope

  • no change to bounty classification logic, closing-reference parsing, reopen policy, or live API semantics
  • no payment execution, treasury mutation, wallet custody, bridge/exchange/off-ramp, or MRWK price behavior
  • no claim that this proposed-work issue is itself an implementation bounty

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions