jackwener/OpenCLI · error · CommandExecutionError
Midjourney API request failed: ${message}
Error message
Midjourney API request failed: ${message} What it means
midjourneyJson rethrows any non-auth HTTP failure as CommandExecutionError('Midjourney API request failed: <message>'). This is the generic transport/request failure path: network errors, 5xx responses, timeouts, DNS failures, or non-401/403 status codes that do not match the auth regex.
Source
Thrown at clis/midjourney/utils.js:284
return path.resolve(expanded);
}
function errorMessage(error) {
return error instanceof Error ? error.message : String(error);
}
async function midjourneyJson(page, endpoint, options = {}) {
try {
return await page.fetchJson(endpoint, {
...options,
headers: { ...CSRF_HEADERS, ...(options.headers || {}) },
});
} catch (error) {
const message = errorMessage(error);
if (/HTTP\s+(401|403)|unauthori[sz]ed|login|sign in/i.test(message)) {
throw new AuthRequiredError(MIDJOURNEY_DOMAIN, 'Log into Midjourney in Chrome, then retry.');
}
throw new CommandExecutionError(`Midjourney API request failed: ${message}`);
}
}
export async function getMidjourneyAccount(page) {
const account = await midjourneyJson(page, '/api/subscriptions-check');
if (!account || typeof account !== 'object' || Array.isArray(account)) {
throw new CommandExecutionError('Midjourney subscription endpoint returned a malformed payload');
}
if (!account.user_id) {
throw new AuthRequiredError(MIDJOURNEY_DOMAIN, 'Log into Midjourney in Chrome, then retry.');
}
return account;
}
export function assertGenerationEntitlement(account) {
if (account.status !== 'active' || !account.plan?.type) {
throw new CommandExecutionError(
'Midjourney generation requires an active subscription.',View on GitHub (pinned to 49907e53dc)
Solutions
- Inspect the wrapped message for the underlying status or cause (e.g. 429 vs 500).
- Retry with exponential backoff for 429/5xx errors after waiting.
- Check Midjourney status / try the endpoint in the logged-in browser to confirm it is not an outage.
- Verify proxy/TLS settings if the message indicates connection or certificate errors.
Example fix
// before
const data = await midjourneyJson(page, url);
// after
const data = await withRetry(() => midjourneyJson(page, url), { retries: 3, backoff: 'exponential' }); Defensive patterns
Strategy: retry
Type guard
function isTransientHttpError(err) {
return /HTTP\s+(429|5\d\d)|timeout|ECONNRESET|ECONNREFUSED|socket/i.test(String(err?.message));
} Try / catch
try {
const data = await midjourneyJson(page, url);
} catch (err) {
if (/Midjourney API request failed/.test(err.message)) {
if (isTransientHttpError(err)) await sleep(backoff(attempt++)); // retry
else throw err;
} else throw err;
} Prevention
- Implement exponential backoff for 429/5xx responses
- Rate-limit outgoing Midjourney calls to stay under thresholds
- Watch Midjourney status pages for outages before batch runs
- Log the underlying message embedded in the wrapper error for diagnosis
When it happens
Trigger: The underlying fetch/request inside midjourneyJson throws with a message not matching the auth regex — e.g. HTTP 429, 500, 502, connection reset, timeout, TLS error.
Common situations: Midjourney API outages or Cloudflare blocks, rate limiting (HTTP 429) after bursts of requests, corporate proxies intercepting TLS, or transient network drops.
Understand the failure class
Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.
Related errors
- arXiv API HTTP ${resp.status}
- mubu: ${path}: HTTP ${result.status} ${result.error ?? ''}
- API_ERROR
- API_ERROR
- API_ERROR
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/8ca418d8e37236a2.
Report an issue: GitHub.