Budibase/budibase · error · HTTPError
Error syncing keys: ${json.error?.message}
Error message
Error syncing keys: ${json.error?.message} What it means
updateKey calls the LiteLLM key management API and, on a non-OK response, joins the fixed prefix "Error syncing keys" with LiteLLM's own error message (json.error?.message) and rethrows as an HTTPError with the upstream status. It surfaces upstream LiteLLM proxy failures (auth, key limits, malformed request) to the caller.
Source
Thrown at packages/server/src/sdk/workspace/ai/configs/litellm.ts:473
"Content-Type": "application/json",
Authorization: liteLLMAuthorizationHeader,
},
body: JSON.stringify({
key: keyId,
...(modelIds ? { models: modelIds } : {}),
...(vectorStoreIds ? { vector_store_ids: vectorStoreIds } : {}),
...(teamId ? { team_id: teamId } : {}),
}),
}
const res = await fetch(`${liteLLMUrl}/key/update`, requestOptions)
const json = await res.json()
if (!res.ok) {
const message = ["Error syncing keys", json.error?.message]
.filter(Boolean)
.join(": ")
throw new HTTPError(message, res.status || 400)
}
}
function isMissingVirtualKeyError(error: any): boolean {
const message = `${error?.message || ""}`.toLowerCase()
const status = error?.status
return status === 401 && message.includes("user key does not exist in db")
}
async function regenerateWorkspaceKey() {
const db = context.getWorkspaceDB()
const keyDocId = docIds.getLiteLLMKeyID()
const workspaceId = context.getProdWorkspaceId()
if (!workspaceId) {
throw new HTTPError("Workspace ID is required to configure LiteLLM", 400)
}View on GitHub (pinned to a81a902e9a)
Solutions
- Read the appended json.error?.message in the thrown error for the upstream cause and fix that first.
- Verify the LiteLLM master key / auth header configured for the server matches the LiteLLM proxy deployment.
- Check that the LiteLLM proxy URL is reachable and healthy (curl its /health endpoint).
- Retry the key sync after fixing upstream; the key doc may need regeneration via regenerateWorkspaceKey.
Example fix
null
Defensive patterns
Strategy: try-catch
Validate before calling
// pre-check proxy availability
const health = await fetch(`${liteLLMUrl}/health`)
if (!health.ok) throw new Error("LiteLLM proxy unavailable before key sync") Try / catch
try {
await updateKey({ keyId, keyName, models })
} catch (e) {
// message is "Error syncing keys: <upstream reason>"
logger.error("LiteLLM key sync failed:", e.message)
if (e.status === 401) throw new Error("Check LITELLM_MASTER_KEY configuration")
throw e
} Prevention
- Monitor LiteLLM proxy health and alert on downtime.
- Keep master key/auth env vars in sync with the proxy deployment.
- Log the full upstream message — it names the actual cause.
When it happens
Trigger: POST to the LiteLLM key endpoint returning 401/400/500 — e.g. wrong LITELLM_MASTER_KEY, key budget exceeded, LiteLLM proxy down or returning an error JSON body.
Common situations: LiteLLM proxy misconfigured or unreachable behind its URL env var; expired/rotated master key in the environment; model budget/max budget settings rejecting key creation.
Related errors
- Error fetching agent log detail: ${text || response.statusTe
- Error fetching agent session detail: ${text || response.stat
- Error fetching LiteLLM providers: ${text || res.statusText}
- Error fetching LiteLLM model cost map: ${text || res.statusT
- Unexpected response when fetching openid-configuration: ${re
AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29).
Data as JSON: /api/errors/7ccfabb596418cfa.
Report an issue: GitHub.