{"record":{"id":"fb354157635ddff0","repo":"paperclipai/paperclip","slug":"trust-proxy-unrecognized-token-json-stringify-t","errorCode":null,"errorMessage":"TRUST_PROXY: unrecognized token ${JSON.stringify(token)} — expected one of {loopback, linklocal, uniquelocal} or a CIDR like 10.0.0.0/8 or fd00::/8","messagePattern":"TRUST_PROXY: unrecognized token (.+?) — expected one of (.+?) or a CIDR like 10\\.0\\.0\\.0/8 or fd00::/8","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/src/middleware/trust-proxy.ts","lineNumber":99,"sourceCode":"  if (value === \"\" || value === \"false\" || value === \"0\") return undefined;\n  if (value === \"true\") return true;\n  if (STRICT_POS_INT_RE.test(value)) return Number(value);\n  // Reject the \"01\" / \" 2\" forms explicitly — if the value is *purely*\n  // digits-or-whitespace but didn't match STRICT_POS_INT_RE, it's a\n  // typo, not a subnet list.\n  if (/^\\s*\\d+\\s*$/.test(raw)) {\n    throw new Error(\n      `TRUST_PROXY: invalid integer value ${JSON.stringify(raw)} — use a positive integer with no leading zeros or whitespace`,\n    );\n  }\n  const tokens = value\n    .split(\",\")\n    .map((t) => t.trim())\n    .filter((t) => t.length > 0);\n  if (tokens.length === 0) return undefined;\n  for (const token of tokens) {\n    if (!isValidSubnetToken(token)) {\n      throw new Error(\n        `TRUST_PROXY: unrecognized token ${JSON.stringify(token)} — expected one of {loopback, linklocal, uniquelocal} or a CIDR like 10.0.0.0/8 or fd00::/8`,\n      );\n    }\n  }\n  return tokens;\n}\n\n/**\n * Apply the parsed value to the given Express app. No-op when the value\n * is `undefined`, preserving Express's default (trust nothing).\n */\nexport function applyTrustProxy(\n  app: { set: (key: string, value: TrustProxyValue) => unknown },\n  value: TrustProxyValue | undefined,\n): void {\n  if (value === undefined) return;\n  app.set(\"trust proxy\", value);\n}","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/paperclipai/paperclip/blob/120ae5428fa29bee300bcf806491cd4d965fbb7c/server/src/middleware/trust-proxy.ts#L81-L117","documentation":"parseTrustProxyEnv token guard: while splitting the comma list, a token was neither a named preset (loopback/linklocal/uniquelocal) nor a parseable CIDR. The message lists the accepted forms so the operator can correct the TRUST_PROXY entry.","triggerScenarios":"Thrown at server/src/middleware/trust-proxy.ts:99 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use one of {loopback, linklocal, uniquelocal} or a valid CIDR such as 10.0.0.0/8 or fd00::/8 in TRUST_PROXY."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"120ae5428fa29bee300bcf806491cd4d965fbb7c","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}