{"record":{"id":"d4d3d2d43adc11b8","repo":"actualbudget/actual","slug":"invalid-name-expected-a-non-negative-integer","errorCode":null,"errorMessage":"Invalid ${name}: expected a non-negative integer, got ${value}","messagePattern":"Invalid (.+?): expected a non-negative integer, got (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/config.ts","lineNumber":140,"sourceCode":"    ],\n  });\n  const result = await explorer.search();\n  if (result && !result.isEmpty) {\n    return validateConfigFileContent(result.config);\n  }\n  return {};\n}\n\nfunction parseNonNegativeIntEnv(\n  raw: string | undefined,\n  source: string,\n): number | undefined {\n  return raw === undefined ? undefined : parseNonNegativeIntFlag(raw, source);\n}\n\nfunction validateNonNegativeInt(value: number, name: string): number {\n  if (!Number.isInteger(value) || value < 0) {\n    throw new Error(\n      `Invalid ${name}: expected a non-negative integer, got ${value}`,\n    );\n  }\n  return value;\n}\n\nexport async function resolveConfig(\n  cliOpts: CliGlobalOpts,\n): Promise<CliConfig> {\n  const fileConfig = await loadConfigFile();\n\n  const serverUrl =\n    cliOpts.serverUrl ??\n    process.env.ACTUAL_SERVER_URL ??\n    fileConfig.serverUrl ??\n    '';\n\n  const password =","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/actualbudget/actual/blob/d4334cb6e6123f4d3bcea1ad6166608884c7e658/packages/cli/src/config.ts#L122-L158","documentation":"validateNonNegativeInt is a final guard applied to resolved numeric options (cacheTtl, lockTimeout) after CLI/env/config merging. It throws when a value reached it that is not an integer or is negative. It backs the earlier parseNonNegativeIntFlag parsing so non-numeric option strings fail too.","triggerScenarios":"Passing --cache-ttl=-1 or --lock-timeout=abc, setting ACTUAL_CACHE_TTL / ACTUAL_LOCK_TIMEOUT to a negative or non-numeric string, or a config file supplying -1 for these keys.","commonSituations":"Using -1 to mean 'infinite' (unsupported); typos like 3o instead of 30; leaving a stray minus sign in an env var.","solutions":["Change the option value to a non-negative integer, e.g. --cache-ttl=300.","Remove the flag/env/config entry to use the default value.","If you need to disable caching, check the docs for the supported mechanism rather than using -1."],"exampleFix":"// before\n$ actual-cli --cache-ttl=-1\n// after\n$ actual-cli --cache-ttl=300","handlingStrategy":"validation","validationCode":"const raw = process.env.ACTUAL_CACHE_TTL;\nif (raw !== undefined && (!/^[0-9]+$/.test(raw) || parseInt(raw, 10) < 0)) {\n  throw new Error(`ACTUAL_CACHE_TTL must be a non-negative integer, got ${raw}`);\n}","typeGuard":"function isNonNegativeInt(v: unknown): v is number {\n  return typeof v === 'number' && Number.isInteger(v) && v >= 0;\n}","tryCatchPattern":"try {\n  await runCommand(argv);\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith('Invalid ')) {\n    console.error(`Bad numeric option: ${err.message}`);\n    process.exit(2);\n  }\n  throw err;\n}","preventionTips":["Validate CLI/env numerics with a regex like ^[0-9]+$ before invoking.","Avoid -1 sentinels; omit the option to use defaults.","Document accepted ranges for cacheTtl/lockTimeout in your team's runbooks.","Parse flags with a typed parser (e.g. commander/zod) that rejects bad ints early."],"tags":["cli","validation","options"],"backgroundTag":"invalid-cli-argument","analyzedSha":"d4334cb6e6123f4d3bcea1ad6166608884c7e658","analyzedAt":"2026-08-29T01:02:11.213Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}