overleaf/overleaf · error · Error
missing filename
Error message
missing filename
What it means
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.
Source
Thrown at services/web/scripts/clear_sessions_set_must_reconfirm.mjs:76
try {
await UserSessionsManager.promises.removeSessionsFromRedis(
{ _id: userId },
null
)
} catch (error) {
console.log(`Failed to clear sessions for ${userId}`, error)
processLogger.failedClear.push(userId)
return
}
processLogger.success.push(userId)
}
async function _loopUsers(userIds) {
return promiseMapWithLimit(ASYNC_LIMIT, userIds, _handleUser)
}
const fileName = process.argv[2]
if (!fileName) throw new Error('missing filename')
const usersFile = fs.readFileSync(fileName, 'utf8')
const userIds = usersFile
.trim()
.split('\n')
.map(id => id.trim())
async function processUsers(userIds) {
console.log('---Starting set_must_reconfirm script---')
_validateUserIdList(userIds)
console.log(`---Starting to process ${userIds.length} users---`)
await _loopUsers(userIds)
processLogger.printSummary()
process.exit()
}
processUsers(userIds)
View on GitHub (pinned to 28ad3b03b7)
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.
Example fix
// before node clear_sessions_set_must_reconfirm.mjs // after node clear_sessions_set_must_reconfirm.mjs ./users.txt
Defensive patterns
Strategy: validation
Validate before calling
if (process.argv.length < 3 || !process.argv[2]) {
console.error('usage: node clear_sessions_set_must_reconfirm.mjs <users-file>')
process.exit(1)
} Type guard
const hasArgs = (argv) => Array.isArray(argv) && typeof argv[2] === 'string' && argv[2].length > 0
Try / catch
try {
await main()
} catch (err) {
if (err.message === 'missing filename') {
console.error('usage: node clear_sessions_set_must_reconfirm.mjs <users-file>')
process.exitCode = 1
} else throw err
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
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 parameter --${flag}
- missing ids list filename
- provide a valid object id as --project-id, --doc-id and --us
- Date must be in YYYY-MM-DD format
- invalid ?editorId
AI-assisted analysis of overleaf/overleaf@28ad3b03b7 (2026-09-03).
Data as JSON: /api/errors/8f91123eef399c32.
Report an issue: GitHub.