{"record":{"id":"a5358020f83d2887","repo":"Stirling-Tools/Stirling-PDF","slug":"failed-to-check-license-key-error-message","errorCode":null,"errorMessage":"Failed to check license key: ${error.message}","messagePattern":"Failed to check license key: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"frontend/editor/src/proprietary/services/licenseService.ts","lineNumber":442,"sourceCode":"  /**\n   * Check if license key is ready for the given installation ID\n   */\n  async checkLicenseKey(installationId: string): Promise<LicenseKeyResponse> {\n    // Check if Supabase is configured\n    if (!isSupabaseConfigured || !supabase) {\n      throw new Error(\n        \"Supabase is not configured. License key lookup is not available.\",\n      );\n    }\n\n    const { data, error } = await supabase.functions.invoke(\"get-license-key\", {\n      body: {\n        installation_id: installationId,\n      },\n    });\n\n    if (error) {\n      throw new Error(`Failed to check license key: ${error.message}`);\n    }\n\n    return data as LicenseKeyResponse;\n  },\n\n  /**\n   * Save license key to backend\n   */\n  async saveLicenseKey(licenseKey: string): Promise<LicenseSaveResponse> {\n    try {\n      const response = await apiClient.post(\"/api/v1/admin/license-key\", {\n        licenseKey: licenseKey,\n      });\n\n      return response.data;\n    } catch (error) {\n      console.error(\"Error saving license key:\", error);\n      throw error;","sourceCodeStart":424,"sourceCodeEnd":460,"githubUrl":"https://github.com/Stirling-Tools/Stirling-PDF/blob/9ef20dcab80b85041912f045e17a6aea1d08f969/frontend/editor/src/proprietary/services/licenseService.ts#L424-L460","documentation":"Thrown by checkLicenseKey when supabase.functions.invoke('get-license-key', ...) returns a non-null error. The get-license-key edge function maps an installation_id to a license record; a returned error means the function failed — invalid installation_id, backend DB error, missing secrets, or a function exception. error.message is wrapped for the caller.","triggerScenarios":"installation_id is empty/malformed; the function can't reach its data store; function deployed without required secrets; the installation has no purchase associated and the function surfaces that as an error rather than {status:'pending'}.","commonSituations":"getInstallationId returned an unexpected value (e.g. 'unknown'); edge function misconfigured; Supabase project paused; race where activation is checked before the purchase webhook completes.","solutions":["Read error.message to determine whether it's an input (installation_id) or backend problem.","Confirm getInstallationId() returns a real MAC-based fingerprint before calling checkLicenseKey.","Verify the get-license-key function is deployed with its required secrets.","Retry after a short delay if the purchase webhook may not have settled yet."],"exampleFix":"// before\nconst res = await licenseService.checkLicenseKey(installationId);\n\n// after\ntry {\n  const res = await licenseService.checkLicenseKey(installationId);\n  if (res.status === 'pending') pollShortly();\n} catch (e) {\n  showToast(e instanceof Error ? e.message : 'License lookup failed');\n}","handlingStrategy":"try-catch","validationCode":"if (!installationId || installationId === 'unknown') {\n  setError('Installation ID not available yet');\n  return;\n}","typeGuard":"export function isValidInstallationId(id: string): boolean {\n  return typeof id === 'string' && id.length > 0 && id !== 'unknown';\n}","tryCatchPattern":"try {\n  const res = await licenseService.checkLicenseKey(installationId);\n  if (res.status === 'pending') setTimeout(retry, 3000);\n} catch (e) {\n  showToast(e instanceof Error ? e.message : 'License lookup failed');\n}","preventionTips":["Confirm getInstallationId returns a real value before lookup.","Verify get-license-key is deployed with its secrets.","Retry once after a short delay in case the purchase webhook hasn't settled."],"tags":["supabase","edge-function","license","activation","proprietary","typescript"],"backgroundTag":null,"analyzedSha":"9ef20dcab80b85041912f045e17a6aea1d08f969","analyzedAt":"2026-08-13T22:11:39.827Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}