mastra-ai/mastra · error
Failed to update Edge Config alias "${options.key}" (${res.s
Error message
Failed to update Edge Config alias "${options.key}" (${res.status}): ${body} What it means
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.
Source
Thrown at deployers/sandbox/src/alias.ts:35
}
const res = await fetch(endpoint, {
method: 'PATCH',
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
items: [{ operation: 'upsert', key: options.key, value: options.url }],
}),
// Bounded so a hung Vercel API request can't keep `mastra build` open
// after the sandbox itself is already deployed.
signal: AbortSignal.timeout(30_000),
});
if (!res.ok) {
const body = await res.text().catch(() => '');
throw new Error(`Failed to update Edge Config alias "${options.key}" (${res.status}): ${body}`);
}
}
View on GitHub (pinned to 75dd419e61)
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.
Example fix
// before (wrong teamId for the Edge Config)
await updateEdgeConfigAlias({ edgeConfigId: 'ecfg_123', key: 'SANDBOX_URL', token, teamId: 'team-wrong', url });
// after
await updateEdgeConfigAlias({ edgeConfigId: 'ecfg_123', key: 'SANDBOX_URL', token, teamId: 'team-correct', url }); Defensive patterns
Strategy: try-catch
Validate before calling
const res0 = await fetch(`https://api.vercel.com/v1/edge-config/${edgeConfigId}?teamId=${teamId}`, { headers: { Authorization: `Bearer ${token}` } });
if (!res0.ok) throw new Error(`Edge Config ${edgeConfigId} not accessible: ${res0.status}`); Type guard
function isVercelApiErrorBody(body: unknown): body is { error: { code: string; message: string } } {
return typeof body === 'object' && body !== null && 'error' in body;
} Try / catch
try {
await updateEdgeConfigAlias(opts);
} catch (err) {
const msg = (err as Error).message;
const status = Number(msg.match(/\((\d{3})\)/)?.[1] ?? 0);
if (status === 429 || status >= 500) {
await new Promise(r => setTimeout(r, 2000));
// retry once
} else {
throw err; // 4xx: config problem, do not retry
}
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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).
Related errors
- Updating the Edge Config alias requires a Vercel API token.
- Failed to fetch CDP version info from ${versionUrl}: ${respo
- Token rotation failed: ${data.error}
- App creation failed: ${errorDetails}
- App deletion failed: ${data.error}
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/5ee6d7b992db65ff.
Report an issue: GitHub.