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

  1. Read the full logAxiosError message — it names the HTTP status and upstream error body, which determines the fix.
  2. For 401/403, rotate/verify openai.apiKey and the OpenAI-Organization header.
  3. For 404, confirm thread_id and run_id exist upstream and were not garbage-collected.
  4. 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

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


AI-assisted analysis of danny-avila/LibreChat@5ff282f900 (2026-08-12). Data as JSON: /api/errors/21ffd56893a393a3. Report an issue: GitHub.