{"record":{"id":"4728e1f4accd2d55","repo":"paperclipai/paperclip","slug":"label-must-be-a-discord-snowflake-id","errorCode":null,"errorMessage":"${label} must be a Discord snowflake ID","messagePattern":"(.+?) must be a Discord snowflake ID","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/src/services/chat-discord.ts","lineNumber":108,"sourceCode":"]);\n\nexport interface DiscordBotIdentity {\n  botAvatarUrl?: string;\n  botExternalId: string;\n  botLabel: string;\n  botUsername: string;\n  providerAccountId: string;\n  providerAccountLabel: string;\n}\n\nfunction requestSignal(): AbortSignal {\n  return AbortSignal.timeout(REQUEST_TIMEOUT_MS);\n}\n\nfunction snowflake(value: string, label: string): string {\n  const normalized = value.trim();\n  if (!/^\\d{17,20}$/.test(normalized)) {\n    throw new Error(`${label} must be a Discord snowflake ID`);\n  }\n  return normalized;\n}\n\nfunction bigint(value: string | undefined): bigint {\n  try {\n    return BigInt(value ?? \"0\");\n  } catch {\n    return 0n;\n  }\n}\n\nasync function discordJson<T>(\n  fetchImpl: typeof globalThis.fetch,\n  token: string,\n  path: string,\n  operation: string,\n): Promise<T> {","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/server/src/services/chat-discord.ts#L90-L126","documentation":"snowflake() normalizes and validates that a Discord ID string is a bare decimal number of 17-20 digits (a Discord snowflake). This template error names the offending field (applicationId, guildId, or botUserId) so the operator knows which configured value is malformed.","triggerScenarios":"Calling verifyDiscordBot (or any consumer of applicationId/guildId/botUserId) with a config value that contains letters, whitespace-padded non-numeric text, is too short/long, or is empty after trim; passing a full Discord mention or URL instead of the raw ID.","commonSituations":"Copy-pasting a Discord channel/invite link instead of the server ID; using developer-mode 'Copy ID' on the wrong entity; an env var left blank or containing quotes; trimming bugs leaving stray characters.","solutions":["Enable Developer Mode in Discord, right-click the server/app, and use 'Copy ID' to get the raw numeric snowflake","Print/inspect the failing config value and strip whitespace, quotes, or URL prefixes so only digits remain","Verify the value length is 17-20 digits (older IDs may be 17-18; padding a short number will not help — get the real ID)"],"exampleFix":"// before\nDISCORD_GUILD_ID=https://discord.gg/myserver\n// after\nDISCORD_GUILD_ID=1234567890123456789","handlingStrategy":"validation","validationCode":"const isSnowflake = (v) => typeof v === \"string\" && /^\\d{17,20}$/.test(v.trim());\nif (!isSnowflake(process.env.DISCORD_GUILD_ID)) throw new Error(\"DISCORD_GUILD_ID must be a 17-20 digit snowflake\");","typeGuard":"const isSnowflake = (v) => typeof v === \"string\" && /^\\d{17,20}$/.test(v.trim());","tryCatchPattern":null,"preventionTips":["Validate Discord ID env vars at startup, before first API call","Use Discord's right-click > Copy ID (Developer Mode) rather than copying links","Never paste mentions (<@123>) or URLs into ID fields","Keep IDs as raw digit strings in config files"],"tags":["discord","config","validation","format"],"backgroundTag":"invalid-identifier-format","analyzedSha":"01ad8584922b5d85292b1723cae71fa0d9b07a19","analyzedAt":"2026-09-10T03:14:50.855Z","contentChangedAt":"2026-09-10T03:14:50.855Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}