{"record":{"id":"5ee6d7b992db65ff","repo":"mastra-ai/mastra","slug":"failed-to-update-edge-config-alias-options-key","errorCode":null,"errorMessage":"Failed to update Edge Config alias \"${options.key}\" (${res.status}): ${body}","messagePattern":"Failed to update Edge Config alias \"(.+?)\" \\((.+?)\\): (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"deployers/sandbox/src/alias.ts","lineNumber":35,"sourceCode":"  }\n\n  const res = await fetch(endpoint, {\n    method: 'PATCH',\n    headers: {\n      Authorization: `Bearer ${token}`,\n      'Content-Type': 'application/json',\n    },\n    body: JSON.stringify({\n      items: [{ operation: 'upsert', key: options.key, value: options.url }],\n    }),\n    // Bounded so a hung Vercel API request can't keep `mastra build` open\n    // after the sandbox itself is already deployed.\n    signal: AbortSignal.timeout(30_000),\n  });\n\n  if (!res.ok) {\n    const body = await res.text().catch(() => '');\n    throw new Error(`Failed to update Edge Config alias \"${options.key}\" (${res.status}): ${body}`);\n  }\n}\n","sourceCodeStart":17,"sourceCodeEnd":38,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/deployers/sandbox/src/alias.ts#L17-L38","documentation":"After PATCHing the Vercel Edge Config items endpoint, the library checks res.ok; if the HTTP response status indicates failure, it throws an Error embedding the Edge Config key, the HTTP status code, and the raw response body from Vercel. This means Vercel rejected the alias update itself — the sandbox deployed, but routing publication failed.","triggerScenarios":"Calling updateEdgeConfigAlias() when the PATCH to https://api.vercel.com/v1/edge-config/{id}/items returns 4xx/5xx: invalid edgeConfigId, token lacking Edge Config write access, wrong teamId, or a malformed items payload / Vercel outage.","commonSituations":"Using an Edge Config ID from a different team than the token's team, passing a teamId that doesn't match the Edge Config's owner, an expired/revoked token, or hitting Vercel rate limits (429).","solutions":["Read the status and body in the thrown message — it contains Vercel's explanation (e.g. 403 forbidden, 404 not found).","Confirm edgeConfigId matches an existing Edge Config in the same team as the token; add/correct teamId if the config belongs to a team.","Regenerate the Vercel token with Edge Config write permissions (read-and-write scope).","Retry on 429/5xx after a delay; Vercel may be rate-limiting or experiencing an incident."],"exampleFix":"// before (wrong teamId for the Edge Config)\nawait updateEdgeConfigAlias({ edgeConfigId: 'ecfg_123', key: 'SANDBOX_URL', token, teamId: 'team-wrong', url });\n// after\nawait updateEdgeConfigAlias({ edgeConfigId: 'ecfg_123', key: 'SANDBOX_URL', token, teamId: 'team-correct', url });","handlingStrategy":"try-catch","validationCode":"const res0 = await fetch(`https://api.vercel.com/v1/edge-config/${edgeConfigId}?teamId=${teamId}`, { headers: { Authorization: `Bearer ${token}` } });\nif (!res0.ok) throw new Error(`Edge Config ${edgeConfigId} not accessible: ${res0.status}`);","typeGuard":"function isVercelApiErrorBody(body: unknown): body is { error: { code: string; message: string } } {\n  return typeof body === 'object' && body !== null && 'error' in body;\n}","tryCatchPattern":"try {\n  await updateEdgeConfigAlias(opts);\n} catch (err) {\n  const msg = (err as Error).message;\n  const status = Number(msg.match(/\\((\\d{3})\\)/)?.[1] ?? 0);\n  if (status === 429 || status >= 500) {\n    await new Promise(r => setTimeout(r, 2000));\n    // retry once\n  } else {\n    throw err; // 4xx: config problem, do not retry\n  }\n}","preventionTips":["Sanity-check edgeConfigId and teamId belong to the same Vercel team before deploying.","Use a token with Edge Config read-and-write scope.","Distinguish retryable (429/5xx) from permanent (4xx) statuses via the status in the message.","Watch Vercel status for incidents when alias updates fail en masse."],"tags":["vercel","edge-config","http-error","api"],"backgroundTag":"http-api-error","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}