remoteintech/remote-jobs · error
Usage: node validate-companies.js <file1.md> [file2.md ...]
Error message
Usage: node validate-companies.js <file1.md> [file2.md ...]
What it means
CLI usage guard at validate-companies.js:209-212. The script reads process.argv.slice(2); if that array is empty it writes the usage line to stderr and calls process.exit(2). Exit code 2 is deliberately distinct from the exit 1 used for validation failures, so callers can tell 'wrong invocation' from 'bad input'.
Source
Thrown at .github/scripts/validate-companies.js:210
function isValidUrl(str) {
try {
const url = new URL(str);
return url.protocol === "https:" || url.protocol === "http:";
} catch {
return false;
}
}
function escapeRegExp(str) {
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
}
// --- Main ---
const args = process.argv.slice(2);
if (args.length === 0) {
console.error("Usage: node validate-companies.js <file1.md> [file2.md ...]");
process.exit(2);
}
// Separate company files from old-format files
const companyFiles = [];
const oldFormatFiles = [];
for (const file of args) {
// Strip pr-head/ prefix used in pull_request_target checkout
const normalized = file.replace(/^pr-head\//, "");
if (normalized.startsWith("company-profiles/")) {
oldFormatFiles.push(normalized);
} else if (normalized.startsWith("src/companies/") && normalized.endsWith(".md")) {
// Store both the actual path (for reading) and the display path (for output)
companyFiles.push({ actual: file, display: normalized });
}
}
View on GitHub (pinned to b1dd8deb19)
Solutions
- Pass one or more .md paths: `node .github/scripts/validate-companies.js src/companies/foo.md`.
- In CI, gate the validator step on a non-empty changed-files list and skip when empty.
- If invoking through npm, use `npm run <script> -- <files>` so args forward correctly.
- Treat exit code 2 in your CI scripts as a configuration error, not a content error.
Example fix
// before node .github/scripts/validate-companies.js // after node .github/scripts/validate-companies.js src/companies/foo.md src/companies/bar.md
Defensive patterns
Strategy: validation
Validate before calling
const files = process.argv.slice(2);
if (files.length === 0) {
console.error('Usage: node validate-companies.js <file1.md> [...]');
process.exit(2);
} Try / catch
const { status } = spawnSync('node', ['.github/scripts/validate-companies.js', ...files]);
if (status === 2) {
// invocation error — fix the caller, don't retry on the same args
throw new Error('validator invoked with no file arguments');
} Prevention
- Gate the CI step on a non-empty changed-files list and skip cleanly when empty.
- Forward args correctly through npm with `--`.
- Treat exit code 2 distinctly from exit 1 in CI reporting.
When it happens
Trigger: Running `node .github/scripts/validate-companies.js` with no arguments; a wrapper npm script that didn't forward `--` args; a GitHub Actions step whose changed-files glob resolved to an empty list, so the validator was invoked with zero paths.
Common situations: Maintainer runs the script locally without args to 'just try it'; the validate-companies.yml workflow computed the diff list but a path filter matched nothing; pull_request_target checkout produced an empty argument string after path normalization.
Related errors
- Could not read file: ${err.message}
- Invalid `website` URL: "${data.website}". Must be a full URL
- Invalid `careers_url`: "${data.careers_url}". Must be a full
AI-assisted analysis of remoteintech/remote-jobs@b1dd8deb19 (2026-08-13).
Data as JSON: /api/errors/d0fb45844eb075d5.
Report an issue: GitHub.