{"record":{"id":"68f96e9d625d7071","repo":"mastra-ai/mastra","slug":"upstash-url-and-token-are-required","errorCode":null,"errorMessage":"Upstash URL and token are required","messagePattern":"Upstash URL and token are required","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/loggers/src/upstash/index.ts","lineNumber":26,"sourceCode":"  maxListLength: number;\n  batchSize: number;\n  flushInterval: number;\n  logBuffer: any[];\n  lastFlush: number;\n  flushIntervalId: NodeJS.Timeout;\n\n  constructor(opts: {\n    listName?: string;\n    maxListLength?: number;\n    batchSize?: number;\n    upstashUrl: string;\n    flushInterval?: number;\n    upstashToken: string;\n  }) {\n    super({ objectMode: true });\n\n    if (!opts.upstashUrl || !opts.upstashToken) {\n      throw new Error('Upstash URL and token are required');\n    }\n\n    this.upstashUrl = opts.upstashUrl;\n    this.upstashToken = opts.upstashToken;\n    this.listName = opts.listName || 'application-logs';\n    this.maxListLength = opts.maxListLength || 10000;\n    this.batchSize = opts.batchSize || 100;\n    this.flushInterval = opts.flushInterval || 10000;\n\n    this.logBuffer = [];\n    this.lastFlush = Date.now();\n\n    // Start flush interval\n    this.flushIntervalId = setInterval(() => {\n      this._flush().catch(err => {\n        console.error('Error flushing logs to Upstash:', err);\n      });\n    }, this.flushInterval);","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/loggers/src/upstash/index.ts#L8-L44","documentation":"The Upstash logger transport pushes logs to an Upstash Redis REST API, which requires both the REST URL and token. The constructor throws 'Upstash URL and token are required' if either opts.upstashUrl or opts.upstashToken is missing or empty.","triggerScenarios":"new UpstashTransport({ upstashUrl: process.env.UPSTASH_URL, upstashToken: process.env.UPSTASH_TOKEN }) where either env var is unset or empty.","commonSituations":"Upstash REST credentials not provisioned in the deployment environment; using the wrong credential type (DB password instead of REST token); typo'd env var names; empty strings from default config templates.","solutions":["Set both upstashUrl (e.g. https://<db>.upstash.io) and upstashToken from your Upstash console REST credentials.","Add a startup env check that fails fast with a clear message before constructing the transport.","Confirm you copied the REST API token (not the database password) from the Upstash console."],"exampleFix":"// before\nconst logger = new UpstashTransport({ upstashUrl: process.env.UPSTASH_URL, upstashToken: process.env.UPSTASH_TOKEN }); // throws if unset\n// after\nif (!process.env.UPSTASH_URL || !process.env.UPSTASH_TOKEN) throw new Error('Set UPSTASH_URL and UPSTASH_TOKEN');\nconst logger = new UpstashTransport({ upstashUrl: process.env.UPSTASH_URL!, upstashToken: process.env.UPSTASH_TOKEN! });","handlingStrategy":"validation","validationCode":"function assertUpstashCreds(opts) {\n  if (!opts.upstashUrl || !opts.upstashToken) {\n    throw new Error('Set UPSTASH_URL and UPSTASH_TOKEN before creating the Upstash transport');\n  }\n}","typeGuard":"function hasUpstashCreds(opts) {\n  return typeof opts.upstashUrl === 'string' && opts.upstashUrl.length > 0 &&\n         typeof opts.upstashToken === 'string' && opts.upstashToken.length > 0;\n}","tryCatchPattern":"try {\n  const logger = new UpstashTransport({ upstashUrl, upstashToken });\n} catch (e) {\n  if (e.message === 'Upstash URL and token are required') {\n    console.error('Upstash REST credentials missing — check UPSTASH_URL / UPSTASH_TOKEN');\n  }\n  throw e;\n}","preventionTips":["Fail fast at startup if UPSTASH_URL/UPSTASH_TOKEN env vars are missing.","Copy credentials from the Upstash console's REST API section (not the DB password).","Keep credentials in secret management, not committed config files."],"tags":["logging","configuration","redis","upstash","validation"],"backgroundTag":"missing-env-var","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}