{"record":{"id":"5d5d13f9563effa3","repo":"paperclipai/paperclip","slug":"label-is-required","errorCode":null,"errorMessage":"${label} is required","messagePattern":"(.+?) is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/src/commands/managed-agent.ts","lineNumber":60,"sourceCode":"  apiKeySecretId: string;\n  model: string;\n  agentId?: string;\n  agentVersion?: string;\n  environmentId?: string;\n  defaultMaxListCostUsd: number;\n}\n\nconst UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;\n\nfunction record(value: unknown): Record<string, unknown> {\n  return value && typeof value === \"object\" && !Array.isArray(value)\n    ? (value as Record<string, unknown>)\n    : {};\n}\n\nfunction required(value: string | undefined, label: string): string {\n  const normalized = value?.trim() ?? \"\";\n  if (!normalized) throw new Error(`${label} is required`);\n  return normalized;\n}\n\nexport function validateManagedAgentSetup(\n  options: ManagedAgentSetupOptions,\n  env: NodeJS.ProcessEnv = process.env,\n): ValidatedSetup {\n  const anthropicApiKey = env.ANTHROPIC_API_KEY?.trim();\n  if (!anthropicApiKey) {\n    throw new Error(\"ANTHROPIC_API_KEY is required in the CLI process environment\");\n  }\n  if (!options.acknowledgeRetention) {\n    throw new Error(\n      \"Pass --acknowledge-retention to enable the stateful beta Managed Agents service\",\n    );\n  }\n\n  const profileKey = required(options.profileKey, \"--profile-key\");","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/paperclipai/paperclip/blob/5716fe907e596ce73501408fc6efdb19fb61edf2/cli/src/commands/managed-agent.ts#L42-L78","documentation":"The private `required` helper throws this when an option value is missing or whitespace-only after trimming. The label is the CLI flag name (e.g. \"--profile-key\"), so the message tells you exactly which flag was omitted. It is a fail-fast input validation guard in `validateManagedAgentSetup` before any network calls are made.","triggerScenarios":"Calling `paperclip managed-agent` setup without supplying one of --profile-key, --display-name, --api-key-secret-id, or --model, or supplying one whose value is empty or only whitespace (e.g. `--display-name \" \"`). Also hit programmatically by calling `validateManagedAgentSetup` with an options object where the corresponding string field is undefined.","commonSituations":"Scripted invocations where an interpolated shell variable is empty; forgetting a flag after copying an example command; CI secrets that resolve to empty strings; typo'd flag names so commander leaves the option undefined.","solutions":["Pass the flag named in the message with a non-empty trimmed value","Check the shell variable feeding the flag actually resolves (echo it before running)","Run `--help` on the managed-agent command to see required flags","If calling validateManagedAgentSetup directly, populate the options object field before invoking"],"exampleFix":"// before\nspawn(\"paperclip\", [\"managed-agent\", \"--profile-key\", profileKey]);\n// after\nspawn(\"paperclip\", [\"managed-agent\", \"--profile-key\", profileKey, \"--display-name\", name, \"--api-key-secret-id\", secretId, \"--model\", \"claude-sonnet-5\"]);","handlingStrategy":"validation","validationCode":"const flags = { profileKey, displayName, apiKeySecretId, model };\nconst missing = Object.entries(flags).filter(([, v]) => !v?.trim()).map(([k]) => k);\nif (missing.length) throw new Error(`Missing required flags: ${missing.join(\", \")}`);","typeGuard":"function isNonEmpty(v: string | undefined): v is string {\n  return typeof v === \"string\" && v.trim().length > 0;\n}","tryCatchPattern":"try {\n  await setupManagedAgent(opts);\n} catch (err) {\n  if (err instanceof Error && err.message.endsWith(\"is required\")) {\n    console.error(`Usage error: ${err.message}`); process.exitCode = 2;\n  } else throw err;\n}","preventionTips":["Build command lines from a single typed options object so no flag can be dropped","Validate all required values before spawning the CLI","Check shell variables are non-empty before interpolation (set -u in bash)","Keep command templates in one place and update them when flags change"],"tags":["cli","input-validation","missing-argument"],"backgroundTag":"missing-required-cli-flag","analyzedSha":"5716fe907e596ce73501408fc6efdb19fb61edf2","analyzedAt":"2026-09-02T18:44:00.616Z","contentChangedAt":"2026-09-02T18:44:00.616Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}