{"record":{"id":"0801bf5c0d6aa5b9","repo":"Stirling-Tools/Stirling-PDF","slug":"license-key-missing-please-contact-support","errorCode":null,"errorMessage":"License key missing. Please contact support.","messagePattern":"License key missing\\. Please contact support\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"frontend/editor/src/proprietary/components/shared/config/configSections/AdminPlanSection.tsx","lineNumber":72,"sourceCode":"    { value: \"idr\", label: \"Indonesian rupiah (IDR, Rp)\" },\n  ];\n\n  const handleManageClick = useCallback(async () => {\n    // Block access if login is disabled\n    if (!validateLoginEnabled()) {\n      return;\n    }\n\n    try {\n      // Only allow PRO or ENTERPRISE licenses to access billing portal\n      if (!licenseInfo?.licenseType || licenseInfo.licenseType === \"NORMAL\") {\n        throw new Error(\n          \"No valid license found. Please purchase a license before accessing the billing portal.\",\n        );\n      }\n\n      if (!licenseInfo?.licenseKey) {\n        throw new Error(\"License key missing. Please contact support.\");\n      }\n\n      // Create billing portal session with license key\n      const response = await licenseService.createBillingPortalSession(\n        window.location.href,\n        licenseInfo.licenseKey,\n      );\n\n      // Open billing portal in new tab\n      window.open(response.url, \"_blank\");\n    } catch (error: unknown) {\n      console.error(\"Failed to open billing portal:\", error);\n      alert({\n        alertType: \"error\",\n        title: t(\"billing.portal.error\", \"Failed to open billing portal\"),\n        body:\n          (error instanceof Error ? error.message : undefined) ||\n          \"Please try again or contact support.\",","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/Stirling-Tools/Stirling-PDF/blob/9ef20dcab80b85041912f045e17a6aea1d08f969/frontend/editor/src/proprietary/components/shared/config/configSections/AdminPlanSection.tsx#L54-L90","documentation":"Thrown by AdminPlanSection.handleManageClick when the license is PRO/ENTERPRISE but licenseInfo.licenseKey is missing. This is an inconsistent state: the system recognizes a paid license type but has no corresponding key to authenticate the billing-portal session request.","triggerScenarios":"licenseType is set to PRO/ENTERPRISE but licenseKey is null/undefined/empty. Partial or corrupted license data in storage. License type was set server-side but the key was never persisted locally.","commonSituations":"Corrupted license record in local storage. Migration issue where licenseType migrated but licenseKey did not. Race condition reading license info before the key was persisted.","solutions":["Re-fetch full license info (including key) from the server and re-persist.","Validate license record integrity on load — ensure both licenseType and licenseKey are present together.","On this error, offer a 'Re-sync license' action that re-pulls the license from the backend."],"exampleFix":"// before\nif (!licenseInfo?.licenseKey) {\n  throw new Error(\"License key missing. Please contact support.\");\n}\n\n// after — treat as recoverable data integrity issue\nif (!licenseInfo?.licenseKey) {\n  await licenseService.refreshLicense();\n  const fresh = await licenseService.getLicenseInfo();\n  if (!fresh?.licenseKey) {\n    alert({ alertType: \"error\", title: t(\"license.keyMissing\", \"License key missing. Please contact support.\") });\n    return;\n  }\n}","handlingStrategy":"fallback","validationCode":"// Validate license record integrity on load\nif (licenseInfo?.licenseType && licenseInfo.licenseType !== \"NORMAL\" && !licenseInfo.licenseKey) {\n  await licenseService.refreshLicense(); // re-pull from server\n}","typeGuard":"function isCompleteLicense(info: { licenseType?: string; licenseKey?: string }): boolean {\n  return !!info.licenseType && !!info.licenseKey;\n}","tryCatchPattern":null,"preventionTips":["Treat a license record with a type but no key as a data-integrity defect and re-sync.","Persist license records atomically (type + key together).","Validate license record shape on load and alert on inconsistency."],"tags":["license","billing","data-integrity","proprietary"],"backgroundTag":null,"analyzedSha":"9ef20dcab80b85041912f045e17a6aea1d08f969","analyzedAt":"2026-08-13T22:11:39.827Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}