{"record":{"id":"d6cdbae75efee7f8","repo":"paperclipai/paperclip","slug":"github-webhook-recovery-invalid-input","errorCode":"github_webhook_recovery_invalid_input","errorMessage":"github_webhook_recovery_invalid_input","messagePattern":"github_webhook_recovery_invalid_input","errorType":"error_code","errorClass":"GitHubWebhookRecoveryError","httpStatus":null,"severity":"error","filePath":"server/src/services/chat-github-webhook-config.ts","lineNumber":114,"sourceCode":"    invalidResponse();\n  return value as Record<string, unknown>;\n}\n\nfunction decimalId(value: unknown): string {\n  if (\n    typeof value !== \"string\" ||\n    !/^[1-9][0-9]{0,19}$/.test(value) ||\n    (value.length === 20 && value > \"18446744073709551615\")\n  )\n    invalidResponse();\n  return value;\n}\n\nfunction inputId(value: unknown): string {\n  try {\n    return decimalId(value);\n  } catch {\n    throw new GitHubWebhookRecoveryError(\n      \"github_webhook_recovery_invalid_input\",\n    );\n  }\n}\n\nfunction optionalId(value: unknown): string | null {\n  return value === undefined || value === null ? null : decimalId(value);\n}\n\nfunction timestamp(value: unknown): string {\n  if (\n    typeof value !== \"string\" ||\n    !/^\\d{4}-\\d\\d-\\d\\dT\\d\\d:\\d\\d:\\d\\d(?:\\.\\d{1,3})?Z$/.test(value) ||\n    !Number.isFinite(Date.parse(value))\n  )\n    invalidResponse();\n  const normalized = value.replace(\n    /(?:\\.(\\d{1,3}))?Z$/,","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/server/src/services/chat-github-webhook-config.ts#L96-L132","documentation":"inputId() validates caller-supplied identifiers (delivery IDs, comment IDs, installation IDs) by delegating to decimalId() and rethrowing failures as github_webhook_recovery_invalid_input. This means the problem is in YOUR input, not GitHub's response: the ID must be a decimal string of 1–20 digits with no leading zeros and within uint64 range.","triggerScenarios":"Calling getGitHubAppWebhookDelivery({deliveryId}), requestGitHubAppWebhookRedelivery({deliveryId}), or getGitHubRecoveryComment({commentId|installationId}) with a value that is not a string matching /^[1-9][0-9]{0,19}$/ — e.g. a number, null, undefined, an empty string, a zero-padded ID like \"007\", or a value exceeding 18446744073709551615.","commonSituations":"Passing a numeric delivery ID straight from JSON without String() conversion; storing IDs in a DB column that stripped leading zeros or coerced to number and lost precision; concatenating prefixes like \"delivery_123\"; receiving undefined because an upstream route param was optional.","solutions":["Coerce to a decimal string first: String(deliveryId) — but only if the source never had leading zeros or precision loss.","Keep GitHub IDs as strings end-to-end (DB column type text/varchar, API fields as string) to avoid Number precision loss.","Validate before calling: if (!/^[1-9][0-9]{0,19}$/.test(id)) reject early with a 400-style error.","Check where the ID originated; if it came from this library's own deliveries list, it is already valid — the corruption happened in your storage layer."],"exampleFix":"// before\nconst detail = await getGitHubAppWebhookDelivery({ fetch, appToken, deliveryId: row.id }); // row.id is a number\n// after\nconst deliveryId = String(row.id);\nif (!/^[1-9][0-9]{0,19}$/.test(deliveryId)) throw new Error(\"bad delivery id\");\nconst detail = await getGitHubAppWebhookDelivery({ fetch, appToken, deliveryId });","handlingStrategy":"validation","validationCode":"function isValidGitHubId(v: unknown): v is string {\n  return typeof v === \"string\" && /^[1-9][0-9]{0,19}$/.test(v) && !(v.length === 20 && v > \"18446744073709551615\");\n}","typeGuard":"function isValidGitHubId(v: unknown): v is string {\n  return typeof v === \"string\" && /^[1-9][0-9]{0,19}$/.test(v);\n}","tryCatchPattern":"try {\n  await getGitHubAppWebhookDelivery({ fetch, appToken, deliveryId });\n} catch (e) {\n  if (e instanceof GitHubWebhookRecoveryError && e.code === \"github_webhook_recovery_invalid_input\") {\n    throw new BadRequest(`deliveryId must be a decimal string: ${typeof deliveryId}`);\n  }\n  throw e;\n}","preventionTips":["Always keep GitHub IDs as strings end-to-end (DB text columns, JSON string fields)","Coerce with String(id) at the boundary, then validate with the decimal regex","Never strip or add leading zeros when persisting IDs"],"tags":["validation","input-validation","github-api","identifier"],"backgroundTag":"invalid-argument-format","analyzedSha":"01ad8584922b5d85292b1723cae71fa0d9b07a19","analyzedAt":"2026-09-10T03:14:50.855Z","contentChangedAt":"2026-09-10T03:14:50.855Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}