{"record":{"id":"f75313c3251c96c7","repo":"paperclipai/paperclip","slug":"environment-variable-opts-valueenv-is-empty-or","errorCode":null,"errorMessage":"Environment variable ${opts.valueEnv} is empty or unset.","messagePattern":"Environment variable (.+?) is empty or unset\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/src/commands/client/secrets.ts","lineNumber":200,"sourceCode":"      secretId,\n      version: \"latest\",\n    };\n  }\n  return next;\n}\n\nfunction asRecord(value: unknown): Record<string, unknown> | null {\n  if (typeof value !== \"object\" || value === null || Array.isArray(value)) return null;\n  return value as Record<string, unknown>;\n}\n\nfunction readValueFromOptions(opts: { value?: string; valueEnv?: string }): string {\n  if (opts.value !== undefined && opts.valueEnv !== undefined) {\n    throw new Error(\"Use only one of --value or --value-env.\");\n  }\n  if (opts.valueEnv !== undefined) {\n    const value = process.env[opts.valueEnv];\n    if (!value) throw new Error(`Environment variable ${opts.valueEnv} is empty or unset.`);\n    return value;\n  }\n  if (opts.value !== undefined) return opts.value;\n  throw new Error(\"Secret value is required. Pass --value or --value-env.\");\n}\n\nfunction renderDeclaration(input: CompanyPortabilityEnvInput): Record<string, unknown> {\n  const scope = input.agentSlug\n    ? `agent:${input.agentSlug}`\n    : input.projectSlug\n      ? `project:${input.projectSlug}`\n      : \"company\";\n  return {\n    key: input.key,\n    scope,\n    kind: input.kind,\n    requirement: input.requirement,\n    portability: input.portability,","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/paperclipai/paperclip/blob/67001ec6eb96ae601aa27bc91d9b2415d665334a/cli/src/commands/client/secrets.ts#L182-L218","documentation":"`readValueFromOptions` takes the `--value-env` branch (only `--value-env` was provided) and reads `process.env[<name>]`. If that variable is unset or empty, it throws naming the variable. Distinct from error 89 only in location (secrets module) and message wording.","triggerScenarios":"Running a secret value command with `--value-env FOO` where `FOO` is not exported or is empty in the current process.","commonSituations":"Env var typo or wrong case; secret not injected in CI; `.env` not sourced; var renamed but flag not updated.","solutions":["Export the named variable: `export FOO=<secret>`","Verify the variable name spelling/case matches what is exported","In CI, confirm the secret is mapped to that exact env var name in the step"],"exampleFix":"# before\npaperclipai secrets set ... --value-env SECRET_VALUE   # SECRET_VALUE unset\n# after\nexport SECRET_VALUE=<secret>\npaperclipai secrets set ... --value-env SECRET_VALUE","handlingStrategy":"validation","validationCode":"function readEnvValueOrThrow(varName: string): string {\n  const value = process.env[varName];\n  if (!value) throw new Error(`Environment variable ${varName} is empty or unset.`);\n  return value;\n}\nconst value = opts.valueEnv ? readEnvValueOrThrow(opts.valueEnv) : opts.value;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Export the named env var before running","Confirm spelling/case of the variable","Inject CI secrets under the exact var name expected by --value-env"],"tags":["cli","secrets","env","validation","credentials"],"backgroundTag":null,"analyzedSha":"67001ec6eb96ae601aa27bc91d9b2415d665334a","analyzedAt":"2026-08-12T12:05:45.408Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}