badges/shields · error
Error processing arguments
Error message
Error processing arguments
What it means
pull-request-services-cli.js is a small CLI that lists the services matching a PR title. It reads the title from process.argv[2]; if fewer than 3 argv entries are present it throws a bare Error caught locally, prints 'Error processing arguments' to stderr and exits with code 1. It is a usage error, not a library exception class.
Source
Thrown at core/service-test-runner/pull-request-services-cli.js:22
// Output the list of services.
//
// Pull request title: [travis sonar] Support user token authentication
//
// Output:
// travis
// sonar
import servicesForTitle from './services-for-title.js'
let title
try {
if (process.argv.length < 3) {
throw new Error()
}
title = process.argv[2]
} catch (e) {
console.error('Error processing arguments')
process.exit(1)
}
console.error(`Title: ${title}\n`)
const services = servicesForTitle(title)
if (services.length === 0) {
console.error('No services found. Nothing to do.')
} else {
console.error(`Services: (${services.length} found) ${services.join(', ')}\n`)
console.log(services.join('\n'))
}
View on GitHub (pinned to 766fd8bc89)
Solutions
- Pass the PR title as the first argument: `node pull-request-services-cli.js "[docker] add foo service"`.
- Quote arguments containing spaces.
- Check the script's usage/header comments for the expected argument order.
- If wrapping the script, forward "$@" so arguments pass through.
Example fix
// before node core/service-test-runner/pull-request-services-cli.js // Error processing arguments (exit 1) // after node core/service-test-runner/pull-request-services-cli.js "[docker] add foo service"
Defensive patterns
Strategy: validation
Validate before calling
if (process.argv.length < 3) { console.error('Usage: node pull-request-services-cli.js "<PR title>"'); process.exit(1) } Type guard
const hasTitleArg = args => Array.isArray(args) && typeof args[2] === 'string' && args[2].length > 0
Try / catch
try {
main(process.argv.slice(2))
} catch (e) {
console.error('Error processing arguments:', e.message)
process.exit(1)
} Prevention
- Always pass the PR title as the first quoted argument.
- Quote titles containing spaces or brackets.
- Check usage docs before invoking maintenance CLIs.
- In wrappers, forward "$@" to preserve arguments.
When it happens
Trigger: Running the script without a title argument, e.g. `node pull-request-services-cli.js` — process.argv.length < 3 so the guard throws.
Common situations: Forgetting to quote a title containing spaces so the shell splits it, invoking via a wrapper that drops arguments, running the wrong file expecting a different CLI signature.
Understand the failure class
Background: "no subcommand specified" and "... is required": CLI errors when a required argument is missing — this error's family across 13 libraries.
AI-assisted analysis of badges/shields@766fd8bc89 (2026-08-30).
Data as JSON: /api/errors/c12046ecd06092f4.
Report an issue: GitHub.