danny-avila/LibreChat · error · Error
[retrieveRun] Failed to retrieve run data:
Error message
[retrieveRun] Failed to retrieve run data:
What it means
Thrown by retrieveRun (Runs/methods.js) when the axios GET to `${baseURL}/threads/${thread_id}/runs/${run_id}` fails. The raw axios error is formatted by logAxiosError and re-thrown as a single Error whose message contains the status, headers, and response body where available. This is the low-level fetch failure that, when repeated, also surfaces as error 166.
Source
Thrown at api/server/services/Runs/methods.js:59
url = `${url}?${queryParams}`;
}
try {
const axiosConfig = {
headers: headers,
timeout: timeout,
};
if (httpAgent) {
axiosConfig.httpAgent = httpAgent;
axiosConfig.httpsAgent = httpAgent;
}
const response = await axios.get(url, axiosConfig);
return response.data;
} catch (error) {
const message = '[retrieveRun] Failed to retrieve run data:';
throw new Error(logAxiosError({ message, error }));
}
}
module.exports = { retrieveRun };
View on GitHub (pinned to 5ff282f900)
Solutions
- Read the full logAxiosError message — it names the HTTP status and upstream error body, which determines the fix.
- For 401/403, rotate/verify openai.apiKey and the OpenAI-Organization header.
- For 404, confirm thread_id and run_id exist upstream and were not garbage-collected.
- For Azure, verify azureConfig.assistants and that openai._options.defaultHeaders/defaultQuery are populated.
Example fix
// before
const data = await retrieveRun({ thread_id, run_id, timeout, openai });
// after
try {
const data = await retrieveRun({ thread_id, run_id, timeout, openai });
} catch (err) {
logger.error('retrieveRun failed:', err.message);
throw err;
} Defensive patterns
Strategy: try-catch
Validate before calling
if (!openai?.apiKey || !openai?.baseURL || !thread_id || !run_id) {
throw new Error('retrieveRun: missing required openai config or ids');
} Try / catch
try {
return await retrieveRun({ thread_id, run_id, timeout, openai });
} catch (err) {
logger.error('retrieveRun failed:', err.message); // logAxiosError details are in err.message
throw err;
} Prevention
- Keep apiKey/baseURL/organization in a single validated config object.
- For Azure, verify azureConfig.assistants and defaultHeaders/defaultQuery.
- Inspect the full logAxiosError message for the exact HTTP status before retrying.
When it happens
Trigger: HTTP 401/403 from a bad apiKey or organization header; 404 from a non-existent thread_id or run_id; 429 rate limiting; 5xx from OpenAI; network/DNS/TLS errors; an AzureOpenAI misconfiguration where the assistants flag or defaultHeaders are wrong; a self-hosted baseURL that is unreachable.
Common situations: Expired or rotated API key; wrong baseURL after migrating between OpenAI and Azure; proxy egress blocked; thread_id/run_id swapped; Azure query params missing.
Related errors
- [waitForRun] ${runIdLog} | Run retrieval failed after ${maxR
- [${req.baseUrl}] Invalid version: ${version}
- Unexpected run status ${run.status}.\nFull run info:\n\n${ru
- no_user_key
- Assistants API key not provided. Please provide it again.
AI-assisted analysis of danny-avila/LibreChat@5ff282f900 (2026-08-12).
Data as JSON: /api/errors/21ffd56893a393a3.
Report an issue: GitHub.