Skip to content

collect-remote: --out, --workflow or --ref with no value is used as the string "true" #270

Closed

Description

@StepenkoAnatoli

What's wrong

parseFlags stores a flag with no value as true. bin/collect-remote.mjs runs checkFlagValues on --max-pages, --depth, --runner, --search-transport and --timeout, but not on --out, --workflow or --ref:

https://github.com/StepenkoAnatoli/Research-Kit/blob/610d353f2c5b81497b34877520c2f0e3bfa61be2/research-kit/bin/collect-remote.mjs#L141-L147

So a bare --out becomes path.resolve(String(true)), which is <cwd>/true. usableOutDir() then creates that folder (fs.mkdirSync(dir, { recursive: true }) in lib/dispatch.mjs), and only after that is the token checked:

https://github.com/StepenkoAnatoli/Research-Kit/blob/610d353f2c5b81497b34877520c2f0e3bfa61be2/research-kit/bin/collect-remote.mjs#L159-L167

Repro, with no GitHub token set:

node research-kit/bin/collect-remote.mjs --repository o/r --topic t --out

This exits 3 with "no GitHub token" and leaves an empty ./true/ folder behind. With a token set, a bare --workflow or --ref would dispatch a run with the literal value "true".

The fix

Add out: 'value', workflow: 'value', ref: 'value' to that checkFlagValues spec. It already turns a valueless flag into --<name> needs a value and exits with EXIT.CANNOT_START, before anything is created or dispatched.

Test

research-kit/test/cli.test.mjs already has several "collect-remote refuses ... before it asks for a token" tests. Add one that runs the command above in a temporary project and asserts:

  • exit status 3
  • stderr matches /--out needs a value/
  • no folder named true exists in the project afterwards

Checking your change

node research-kit/bin/selftest.mjs cli

Activity

  1. StepenkoAnatoli commented on Oct 11, 2026

    @StepenkoAnatoli
    OwnerAuthor

    Fix is in #281 (out: {}, workflow: {}, ref: {} in the checkFlagValues spec, the regression test this issue asked for, README inventory 1787, map row and CHANGELOG). It is the remedy #276 carried, with @bonilokesh credited as co-author.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions