Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix: default to cwd when --reach is used without explicit target
When `socket scan create --reach` is run without an explicit target path,
the CLI previously relied on an interactive prompt to ask the user to
confirm the current directory. In non-TTY environments (e.g. Jenkins CI),
the select() prompt silently fails because wrapPrompt swallows non-TypeError
errors, causing suggestTarget() to return [] and all reach validations to
fail with confusing "Input error: At least one TARGET (missing)" errors.

Now falls back to '.' (cwd) when the prompt returns empty, preserving the
interactive prompt for TTY users while gracefully handling non-TTY
environments.

Also bumps @coana-tech/cli to 14.12.200 and CLI version to 1.1.74.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
  • Loading branch information
mtorp and claude committed Mar 19, 2026
commit 35a901c5aef1fc69323ae41c320a0c927d76d371
19 changes: 10 additions & 9 deletions src/commands/scan/cmd-scan-create.mts
Original file line number Diff line number Diff line change
Expand Up @@ -381,21 +381,22 @@ async function run(
let updatedInput = false

// Accept zero or more paths. Default to cwd() if none given.
// Note: cli.input is always an array (even if empty), so || [cwd] never
// fires because [] is truthy. Use .length check instead.
let targets = cli.input.length ? cli.input : []

if (!targets.length && reach) {
// --reach requires exactly one directory target; default to cwd rather
// than relying on an interactive prompt that fails in non-TTY environments
// such as Jenkins CI (the select() prompt silently returns undefined when
// stdin is not a TTY, causing all downstream validations to fail).
targets = ['.']
} else if (!targets.length && !dryRun && interactive) {
if (!targets.length && !dryRun && interactive) {
targets = await suggestTarget()
Comment thread
mtorp marked this conversation as resolved.
updatedInput = true
}

// Fallback: if targets is still empty after the interactive prompt (e.g. the
// select() prompt silently fails in non-TTY environments like Jenkins CI
// because wrapPrompt swallows non-TypeError errors and returns undefined),
// default to '.' so that downstream validations don't fail with confusing
// "At least one TARGET (missing)" errors.
if (!targets.length && !dryRun) {
targets = ['.']
}

// We're going to need an api token to suggest data because those suggestions
// must come from data we already know. Don't error on missing api token yet.
// If the api-token is not set, ignore it for the sake of suggestions.
Expand Down
Loading