{"record":{"id":"cb00c036ef1d44ad","repo":"actualbudget/actual","slug":"invalid-name-must-be-a-non-empty-string","errorCode":null,"errorMessage":"Invalid --name: must be a non-empty string.","messagePattern":"Invalid --name: must be a non-empty string\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/commands/accounts.ts","lineNumber":80,"sourceCode":"          );\n          printOutput({ id }, opts.format);\n        },\n        { mutates: true },\n      );\n    });\n\n  accounts\n    .command('update <id>')\n    .description('Update an account')\n    .option('--name <name>', 'New account name')\n    .option('--offbudget <bool>', 'Set off-budget status')\n    .action(async (id: string, cmdOpts) => {\n      const opts = program.opts();\n      const fields: Record<string, unknown> = {};\n      if (cmdOpts.name !== undefined) {\n        const trimmed = cmdOpts.name.trim();\n        if (trimmed === '') {\n          throw new Error('Invalid --name: must be a non-empty string.');\n        }\n        fields.name = trimmed;\n      }\n      if (cmdOpts.offbudget !== undefined) {\n        fields.offbudget = parseBoolFlag(cmdOpts.offbudget, '--offbudget');\n      }\n      if (Object.keys(fields).length === 0) {\n        throw new Error(\n          'No update fields provided. Use --name or --offbudget.',\n        );\n      }\n      await withConnection(\n        opts,\n        async () => {\n          await api.updateAccount(id, fields);\n          printOutput({ success: true, id }, opts.format);\n        },\n        { mutates: true },","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/actualbudget/actual/blob/d4334cb6e6123f4d3bcea1ad6166608884c7e658/packages/cli/src/commands/accounts.ts#L62-L98","documentation":"The accounts CLI `update` command validates --name before building the update fields. Passing --name with only whitespace (e.g. --name \" \") is rejected because an empty name is not a meaningful account update. The CLI throws synchronously in the command action.","triggerScenarios":"Running `actual-cli accounts update <id> --name \" \"` (or tabs/whitespace) — the trimmed value is empty so the guard fires.","commonSituations":"Shell variables that expand to empty or spaces (NAME=\"$BLANK\"); copy-pasted commands with trailing whitespace; scripted batch updates where a CSV field was blank.","solutions":["Pass a non-empty name: `accounts update <id> --name \"Checking\"`.","Check the shell variable actually contains a value before invoking the CLI.","If you intended not to rename, omit --name entirely."],"exampleFix":"// before\nNAME=\"   \"\nactual accounts update abc123 --name \"$NAME\"\n// after\nNAME=\"Checking\"\n[ -n \"$(echo \"$NAME\" | tr -d '[:space:]')\" ] && actual accounts update abc123 --name \"$NAME\"","handlingStrategy":"validation","validationCode":"const name = (process.argv[3] ?? '').trim();\nif (!name) {\n  console.error('Provide a non-empty --name');\n  process.exit(2);\n}\n// then: accounts update <id> --name \"$name\"","typeGuard":"function isNonEmptyString(v: unknown): v is string {\n  return typeof v === 'string' && v.trim().length > 0;\n}","tryCatchPattern":"try {\n  await runCli(['accounts', 'update', id, '--name', name]);\n} catch (e) {\n  if (String(e.message).includes('Invalid --name')) {\n    console.error('Account name cannot be blank — supply a real name.');\n    process.exitCode = 2;\n  } else throw e;\n}","preventionTips":["Trim and check shell variables before interpolating into --name.","Quote all flag values in scripts to avoid whitespace-only args.","Omit --name entirely when not renaming.","Add a preflight non-empty check in batch-update scripts."],"tags":["cli","validation","arguments","accounts"],"backgroundTag":"invalid-command-argument","analyzedSha":"d4334cb6e6123f4d3bcea1ad6166608884c7e658","analyzedAt":"2026-08-29T01:02:11.213Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}