{"record":{"id":"6d6255ac27d01e3f","repo":"jackwener/OpenCLI","slug":"midjourney-generation-requires-an-active-subscript","errorCode":null,"errorMessage":"Midjourney generation requires an active subscription.","messagePattern":"Midjourney generation requires an active subscription\\.","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/midjourney/utils.js","lineNumber":301,"sourceCode":"    }\n    throw new CommandExecutionError(`Midjourney API request failed: ${message}`);\n  }\n}\n\nexport async function getMidjourneyAccount(page) {\n  const account = await midjourneyJson(page, '/api/subscriptions-check');\n  if (!account || typeof account !== 'object' || Array.isArray(account)) {\n    throw new CommandExecutionError('Midjourney subscription endpoint returned a malformed payload');\n  }\n  if (!account.user_id) {\n    throw new AuthRequiredError(MIDJOURNEY_DOMAIN, 'Log into Midjourney in Chrome, then retry.');\n  }\n  return account;\n}\n\nexport function assertGenerationEntitlement(account) {\n  if (account.status !== 'active' || !account.plan?.type) {\n    throw new CommandExecutionError(\n      'Midjourney generation requires an active subscription.',\n      `Check the account at ${MIDJOURNEY_URL}/account.`,\n    );\n  }\n  const remaining = Number(account.total_credits ?? account.credits_total ?? 0);\n  if (!(remaining > 0) && !account.abilities?.can_relax) {\n    throw new CommandExecutionError(\n      'No Midjourney generation credits remain for this billing period.',\n      `Check usage at ${MIDJOURNEY_URL}/account.`,\n    );\n  }\n}\n\nexport async function fetchHistory(page, userId, limit = 20) {\n  return (await fetchHistoryPage(page, userId, limit)).data;\n}\n\nexport async function fetchHistoryPage(page, userId, limit = 20, cursor = null) {","sourceCodeStart":283,"sourceCodeEnd":319,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/midjourney/utils.js#L283-L319","documentation":"assertGenerationEntitlement checks the account payload from subscriptions-check and throws CommandExecutionError when status !== 'active' or plan.type is missing. Generation is impossible without an active subscription, so the CLI fails fast with a pointer to the account page instead of submitting doomed jobs.","triggerScenarios":"Called after getMidjourneyAccount with account.status not equal to 'active' or account.plan?.type falsy — e.g. trial ended, subscription lapsed, payment failed, or account is on a plan type the payload does not report.","commonSituations":"Billing renewal failed, user cancelled subscription, new account with no plan, or Midjourney renaming plan fields so the check misreads an active account as inactive.","solutions":["Visit midjourney.com/account and renew/reactivate the subscription.","Verify payment method is valid and the latest invoice was paid.","Confirm the account payload actually shows status 'active'; if it does but the error still fires, the CLI's field expectations may be outdated — update the library."],"exampleFix":"// before\nawait assertGenerationEntitlement(account); // throws on lapsed plan\n// after\nif (account.status !== 'active') {\n  console.error('Subscription inactive — renew at midjourney.com/account');\n  process.exit(1);\n}\nawait assertGenerationEntitlement(account);","handlingStrategy":"validation","validationCode":"const account = await getMidjourneyAccount(page);\nconst canGenerate = account.status === 'active' && Boolean(account.plan?.type);\nif (!canGenerate) console.error('Subscription inactive — renew at midjourney.com/account before generating.');","typeGuard":"function hasActiveSubscription(account) {\n  return account != null && typeof account === 'object' && account.status === 'active' &&\n    typeof account.plan === 'object' && account.plan !== null && Boolean(account.plan.type);\n}","tryCatchPattern":"try {\n  assertGenerationEntitlement(account);\n} catch (err) {\n  if (/requires an active subscription/.test(err.message)) {\n    console.error('Renew your plan at midjourney.com/account.');\n  } else throw err;\n}","preventionTips":["Check subscription status before batch generation runs","Keep billing payment methods current","Call assertGenerationEntitlement early, before any submit","Watch for plan-field renames when updating Midjourney integrations"],"tags":["midjourney","subscription","entitlement","billing"],"backgroundTag":"subscription-required","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}