{"record":{"id":"95779aaca365e265","repo":"overleaf/overleaf","slug":"missing-hashes-flag","errorCode":null,"errorMessage":"missing --hashes flag","messagePattern":"missing --hashes flag","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"services/history-v1/storage/scripts/verify_backup_blob.mjs","lineNumber":11,"sourceCode":"import logger from '@overleaf/logger'\nimport commandLineArgs from 'command-line-args'\nimport { verifyBlobs } from '../lib/backupVerifier.mjs'\n\nconst { historyId, hashes } = commandLineArgs([\n  { name: 'historyId', type: String },\n  { name: 'hashes', type: String, multiple: true, defaultOption: true },\n])\n\nif (hashes.length === 0) {\n  throw new Error('missing --hashes flag')\n}\n\ntry {\n  await verifyBlobs(historyId, hashes)\n  console.log('OK')\n  process.exit(0)\n} catch (err) {\n  logger.err({ err }, 'failed to verify blob')\n  process.exit(1)\n}\n","sourceCodeStart":1,"sourceCodeEnd":22,"githubUrl":"https://github.com/overleaf/overleaf/blob/28ad3b03b71cb4311decdcb55c36b33ec10d72db/services/history-v1/storage/scripts/verify_backup_blob.mjs#L1-L22","documentation":"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.","triggerScenarios":"Running the script without any positional hash arguments (or with an empty --hashes), even if --historyId is present.","commonSituations":"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.","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."],"exampleFix":"// before\nnode verify_backup_blob.mjs --historyId 65a1...\n// after\nnode verify_backup_blob.mjs --historyId 65a1... --hashes e5fa44f2b31c1fb553b6021e7360d07d5d91ff5e","handlingStrategy":"validation","validationCode":"const HASH_RE = /^[0-9a-f]{40,64}$/i\nconst hashes = process.argv.slice(2).filter(a => HASH_RE.test(a))\nif (hashes.length === 0) {\n  console.error('Usage: verify_backup_blob.mjs --historyId <id> --hashes <hash...>')\n  process.exit(1)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["cli-args","validation","maintenance-script"],"backgroundTag":"missing-required-argument","analyzedSha":"28ad3b03b71cb4311decdcb55c36b33ec10d72db","analyzedAt":"2026-09-03T02:10:22.807Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T07:17:11.731Z"}