{"record":{"id":"8f91123eef399c32","repo":"overleaf/overleaf","slug":"missing-filename","errorCode":null,"errorMessage":"missing filename","messagePattern":"missing filename","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"services/web/scripts/clear_sessions_set_must_reconfirm.mjs","lineNumber":76,"sourceCode":"  try {\n    await UserSessionsManager.promises.removeSessionsFromRedis(\n      { _id: userId },\n      null\n    )\n  } catch (error) {\n    console.log(`Failed to clear sessions for ${userId}`, error)\n    processLogger.failedClear.push(userId)\n    return\n  }\n  processLogger.success.push(userId)\n}\n\nasync function _loopUsers(userIds) {\n  return promiseMapWithLimit(ASYNC_LIMIT, userIds, _handleUser)\n}\n\nconst fileName = process.argv[2]\nif (!fileName) throw new Error('missing filename')\nconst usersFile = fs.readFileSync(fileName, 'utf8')\nconst userIds = usersFile\n  .trim()\n  .split('\\n')\n  .map(id => id.trim())\n\nasync function processUsers(userIds) {\n  console.log('---Starting set_must_reconfirm script---')\n  _validateUserIdList(userIds)\n  console.log(`---Starting to process ${userIds.length} users---`)\n  await _loopUsers(userIds)\n\n  processLogger.printSummary()\n  process.exit()\n}\n\nprocessUsers(userIds)\n","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/overleaf/overleaf/blob/28ad3b03b71cb4311decdcb55c36b33ec10d72db/services/web/scripts/clear_sessions_set_must_reconfirm.mjs#L58-L94","documentation":"The script reads its only required CLI argument (process.argv[2]) as the path to a file of user IDs; if no argument is supplied it throws 'missing filename'. This is a fail-fast guard before any file I/O or DB access. It indicates the script was invoked without the expected positional argument.","triggerScenarios":"Running `node clear_sessions_set_must_reconfirm.mjs` with no arguments, or passing flags (e.g. `-f users.txt`) that minimist-style parsing would consume but argv[2] does not hold, or running it from a wrapper that drops arguments.","commonSituations":"Forgetting the argument after copy-pasting docs; an npm/Make wrapper swallowing args; IDE run configurations with an empty 'arguments' field; calling the script programmatically without simulating argv.","solutions":["Pass the file as the first positional argument: node clear_sessions_set_must_reconfirm.mjs path/to/users.txt.","If using npm scripts, add -- before the filename so it forwards arguments: npm run script -- users.txt.","Check the run configuration/wrapper actually forwards the argument to the node process.","Add an explicit usage message if this is your fork: print usage when !fileName instead of throwing bare."],"exampleFix":"// before\nnode clear_sessions_set_must_reconfirm.mjs\n// after\nnode clear_sessions_set_must_reconfirm.mjs ./users.txt","handlingStrategy":"validation","validationCode":"if (process.argv.length < 3 || !process.argv[2]) {\n  console.error('usage: node clear_sessions_set_must_reconfirm.mjs <users-file>')\n  process.exit(1)\n}","typeGuard":"const hasArgs = (argv) => Array.isArray(argv) && typeof argv[2] === 'string' && argv[2].length > 0","tryCatchPattern":"try {\n  await main()\n} catch (err) {\n  if (err.message === 'missing filename') {\n    console.error('usage: node clear_sessions_set_must_reconfirm.mjs <users-file>')\n    process.exitCode = 1\n  } else throw err\n}","preventionTips":["Always pass the filename as the first positional argument, not a flag","Use `npm run script -- file.txt` to forward args through npm scripts","Check IDE run configs include the argument","Prefer explicit usage messages in wrappers around this script"],"tags":["cli-arguments","missing-argument","input-validation"],"backgroundTag":"missing-required-argument","analyzedSha":"28ad3b03b71cb4311decdcb55c36b33ec10d72db","analyzedAt":"2026-09-03T02:10:22.807Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T07:17:11.731Z"}