overleaf/overleaf · error
missing --hashes flag
Error message
missing --hashes flag
What it means
verify_backup_blob.mjs parses command-line args with command-line-args and immediately validates that at least one hash was provided. Since --hashes accepts multiple values as the default option, an empty list means no hashes were supplied and there is nothing to verify, so the script fails fast.
Source
Thrown at services/history-v1/storage/scripts/verify_backup_blob.mjs:11
import logger from '@overleaf/logger'
import commandLineArgs from 'command-line-args'
import { verifyBlobs } from '../lib/backupVerifier.mjs'
const { historyId, hashes } = commandLineArgs([
{ name: 'historyId', type: String },
{ name: 'hashes', type: String, multiple: true, defaultOption: true },
])
if (hashes.length === 0) {
throw new Error('missing --hashes flag')
}
try {
await verifyBlobs(historyId, hashes)
console.log('OK')
process.exit(0)
} catch (err) {
logger.err({ err }, 'failed to verify blob')
process.exit(1)
}
View on GitHub (pinned to 28ad3b03b7)
Solutions
- Pass one or more hashes as positional args: --hashes <hash1> <hash2>.
- Check that the shell variable containing hashes is non-empty before invoking.
- Use the correct flag spelling --hashes (plural).
- Add a validation for missing --historyId too, which currently would fail later inside verifyBlobs.
Example fix
// before node verify_backup_blob.mjs --historyId 65a1... // after node verify_backup_blob.mjs --historyId 65a1... --hashes e5fa44f2b31c1fb553b6021e7360d07d5d91ff5e
Defensive patterns
Strategy: validation
Validate before calling
const HASH_RE = /^[0-9a-f]{40,64}$/i
const hashes = process.argv.slice(2).filter(a => HASH_RE.test(a))
if (hashes.length === 0) {
console.error('Usage: verify_backup_blob.mjs --historyId <id> --hashes <hash...>')
process.exit(1)
} Prevention
- Quote shell variables holding hashes and check they are non-empty.
- Remember hashes are the default (positional) option.
- Add a --historyId presence check too.
- Validate hash hex format before invoking.
When it happens
Trigger: Running the script without any positional hash arguments (or with an empty --hashes), even if --historyId is present.
Common situations: Forgetting that hashes are the default option and passing them after another flag in a way that isn't captured; shell variable holding hashes expands to empty; typo'd flag name like --hash instead of --hashes.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- missing --output
- use --BATCH_RANGE_START and --BATCH_RANGE_END
- cipherLabel cannot be empty
- cipherLabel must not contain a colon (:), got ${cipherLabel}
- cipherLabel must contain version suffix (e.g. 2042.1-v42), g
AI-assisted analysis of overleaf/overleaf@28ad3b03b7 (2026-09-03).
Data as JSON: /api/errors/95779aaca365e265.
Report an issue: GitHub.