hcengineering/platform · error
Failed to fetch deepgram requests ${res.status}: ${text}
Error message
Failed to fetch deepgram requests ${res.status}: ${text} What it means
fetchDeepgramRequests calls the Deepgram API to fetch usage/request records; when the HTTP response is not ok, it logs the status and body via ctx.error and throws an Error embedding both. This means the Deepgram request itself failed (auth, bad query params, rate limiting, or upstream outage) and no billing data could be retrieved.
Source
Thrown at services/ai-bot/pod-ai-bot/src/billing.ts:85
}
if (end != null) {
url.searchParams.set('end', end.toISOString())
}
if (page != null) {
url.searchParams.set('page', page.toString())
}
url.searchParams.set('limit', '100')
const res = await fetch(url, {
headers: { Authorization: `Token ${config.DeepgramApiKey}` }
})
if (!res.ok) {
const text = await res.text()
ctx.error('Failed to fetch deepgram requests', { status: res.status, text })
throw new Error(`Failed to fetch deepgram requests ${res.status}: ${text}`)
}
return await res.json()
}
function extractExtra (path: string): Record<string, any> {
try {
const query = path.split('?')[1]
if (query == null) return {}
const params = new URLSearchParams(query)
const extras = params.getAll('extra')
return Object.fromEntries(extras.map((pair) => pair.split(':', 2)).filter(([k, v]) => k != null && v != null))
} catch {
return {}
}
}
function extractWorkspace (req: DeepgramRequest): WorkspaceUuid | undefined {View on GitHub (pinned to 63e28dc964)
Solutions
- Check config.DeepgramApiKey is set and valid (test with a simple Deepgram API call)
- Inspect res.status and the body text in the error/log to identify auth vs bad-request vs server error
- Verify the request URL, project id and query parameters against current Deepgram API docs
- Retry with backoff if status is 429/5xx
Example fix
// before
headers: { Authorization: `Token ${config.DeepgramApiKey}` }
// after (fail fast with a clear config check)
if (!config.DeepgramApiKey) throw new Error('DeepgramApiKey is not configured')
headers: { Authorization: `Token ${config.DeepgramApiKey}` } Defensive patterns
Strategy: try-catch
Validate before calling
if (!config.DeepgramApiKey) {
throw new Error('DEEPGRAM API key missing: set config.DeepgramApiKey before fetching usage')
} Try / catch
try {
const requests = await billing.fetchDeepgramRequests(params)
} catch (err) {
const msg = err instanceof Error ? err.message : String(err)
const status = Number(msg.match(/requests (\d{3})/)?.[1] ?? 0)
if (status === 401 || status === 403) console.error('Check Deepgram API key')
else if (status === 429 || status >= 500) scheduleRetryWithBackoff()
else console.error('Deepgram request failed:', msg)
} Prevention
- Validate DeepgramApiKey presence at service startup
- Log res.status and body on every non-ok response for diagnosis
- Add retry with exponential backoff for 429/5xx responses
- Pin and monitor Deepgram API version; alert on sustained failures in the billing job
When it happens
Trigger: Any Deepgram HTTP response with res.ok === false: invalid or missing DEEPGRAM API key (401/403), malformed date-range/project-id query parameters (400), rate limits (429), or Deepgram service errors (5xx).
Common situations: Expired or rotated Deepgram API key in config; wrong project id in the request URL; billing job querying a time range before the project existed; Deepgram outage or network proxy returning error pages.
Related errors
- response.statusText
- Failed to fetch config
- unknownError(response.statusText)
- Failed to delete file
- Failed to delete file
AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29).
Data as JSON: /api/errors/f6f195bcf9828878.
Report an issue: GitHub.