{"record":{"id":"c0ea13638cc3c14a","repo":"anomalyco/sst","slug":"this-name","errorCode":null,"errorMessage":"${this._name}","messagePattern":"\\$\\{this\\._name\\}","errorType":"exception","errorClass":"SecretMissingError","httpStatus":null,"severity":"error","filePath":"platform/src/components/secret.ts","lineNumber":126,"sourceCode":"   * @param placeholder A placeholder value of the secret. This can be useful for cases where you might not be storing sensitive values.\n\n   */\n  constructor(name: string, placeholder?: Input<string>) {\n    super(\n      \"sst:sst:Secret\",\n      name,\n      {\n        placeholder,\n      },\n      {},\n    );\n    this._name = name;\n    this._placeholder = placeholder !== undefined ? output(placeholder) : undefined;\n    this._value = output(\n      process.env[\"SST_SECRET_\" + this._name] ?? this._placeholder,\n    ).apply((value) => {\n      if (typeof value !== \"string\") {\n        throw new SecretMissingError(this._name);\n      }\n      return value;\n    });\n  }\n\n  /**\n   * The name of the secret.\n   */\n  public get name() {\n    return output(this._name);\n  }\n\n  /**\n   * The value of the secret. It'll be `undefined` if the secret has not been set through the CLI or if the `placeholder` hasn't been set.\n   */\n  public get value() {\n    return secret(this._value);\n  }","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/platform/src/components/secret.ts#L108-L144","documentation":"`Secret` resolves its value from the `SST_SECRET_<NAME>` environment variable injected by SST, falling back to the optional `placeholder` argument. If neither exists, the resolved value is undefined and the constructor throws `SecretMissingError`, which tells you to run `sst secret set <Name> <value>`.","triggerScenarios":"Calling `new sst.Secret(\"MySecret\")` with no placeholder while the secret has never been set via `sst secret set` (no `SST_SECRET_MySecret` env var is present in the deploy process). Also occurs in CI/PR stages where the secret has no stage value and no `--fallback` was set.","commonSituations":"Fresh machine or CI environment missing `sst secret set` for the current stage; deploying a PR/preview stage that has no secret value and no fallback; typo in the secret name so SST injects a different env var; forgetting the placeholder argument during local-first development.","solutions":["Run `sst secret set MySecret <value>` (with the current `--stage` if needed), then redeploy.","Set a placeholder in code if the value is not sensitive: `new sst.Secret(\"MySecret\", \"fallback-value\")`.","For PR/preview stages, set a fallback value: `sst secret set MySecret <value> --fallback`.","Verify the exact secret name matches everywhere — names are case-sensitive for the SST_SECRET_<NAME> env var lookup.","In CI, ensure secrets are set for that stage (or use the fallback) before running `sst deploy`."],"exampleFix":"// before\nconst secret = new sst.Secret(\"StripeKey\");\n// after (set the value first)\n//   sst secret set StripeKey sk_live_... --fallback\nconst secret = new sst.Secret(\"StripeKey\");","handlingStrategy":"validation","validationCode":"// Before constructing the Secret, check it has been set\nconst name = \"StripeKey\";\nif (!process.env[`SST_SECRET_${name}`]) {\n  throw new Error(`Run: sst secret set ${name} <value> (or pass a placeholder)`);\n}\nconst secret = new sst.Secret(name);","typeGuard":"function hasSecret(name: string): boolean {\n  return typeof process.env[`SST_SECRET_${name}`] === \"string\";\n}","tryCatchPattern":"try {\n  const secret = new sst.Secret(\"StripeKey\");\n} catch (e) {\n  if (String(e).includes(\"sst secret set\")) {\n    console.error(\"Secret StripeKey is unset for this stage. Run: sst secret set StripeKey <value>\");\n  }\n  throw e;\n}","preventionTips":["Run `sst secret set <Name> <value>` for every stage before deploying","Use `--fallback` for values shared by PR/preview stages","Pass a placeholder argument when the value is not sensitive","Keep secret names in a constants file to avoid case-sensitive typos","Document required secrets in CI setup so pipelines set them before deploy"],"tags":["sst","secret","missing-value","configuration","environment"],"backgroundTag":"missing-secret-value","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}