{"record":{"id":"367ede5379a47699","repo":"toeverything/AFFiNE","slug":"license-not-found-367ede","errorCode":"license_not_found","errorMessage":"License not found.","messagePattern":"License not found\\.","errorType":"exception","errorClass":"LicenseNotFound","httpStatus":404,"severity":"error","filePath":"packages/backend/server/src/plugins/payment/license/controller.ts","lineNumber":150,"sourceCode":"  @Get('/:license/health')\n  async health(\n    @Res() res: Response,\n    @Param('license') key: string,\n    @Headers('x-validate-key') revalidateKey: string\n  ) {\n    const license = await this.db.license.findUnique({\n      where: {\n        key,\n      },\n    });\n\n    const subscription = await this.manager.getActiveSubscription({\n      key,\n      plan: SubscriptionPlan.SelfHostedTeam,\n    });\n\n    if (!license || !subscription) {\n      throw new LicenseNotFound();\n    }\n\n    if (!license.validateKey || license.validateKey !== revalidateKey) {\n      throw new InvalidLicenseToActivate({\n        reason: 'Invalid validate key',\n      });\n    }\n\n    const validateKey = randomUUID();\n    await this.db.license.update({\n      where: {\n        key,\n      },\n      data: {\n        validateKey,\n      },\n    });\n","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/b4c8548c09da21b2898443559a5b846f0ccf5dd8/packages/backend/server/src/plugins/payment/license/controller.ts#L132-L168","documentation":"LicenseNotFound thrown at packages/backend/server/src/plugins/payment/license/controller.ts:150 in GET /api/team/licenses/:license/health when either the license row is missing from the database or manager.getActiveSubscription for the SelfHostedTeam plan returns null. It is the resource-lookup failure of the periodic health/revalidation endpoint (resource_not_found class).","triggerScenarios":"Health-checking a key that was never inserted into the license table (typo, wrong env), or whose subscription record no longer resolves (subscription deleted/ended in billing, plan mismatch); a node health-checking a license that was deactivated and purged.","commonSituations":"Monitoring scripts retaining an old license key after renewal/change; billing-side subscription removal; DB restored from backup missing license rows.","solutions":["Confirm the key in the health-check URL matches the activated license exactly.","Verify the license row and its active subscription exist (SELECT from license; check subscription status/plan in billing).","If the subscription truly ended, stop health-checking and re-activate a valid license.","Update monitoring/agent configuration to use the current license key."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"const res = await fetch(`/api/team/licenses/${key}/health`, { headers: { 'x-validate-key': storedKey } });\nif (res.status === 404) {\n  // LicenseNotFound: stop monitoring this key, re-activate a valid license\n}","preventionTips":["Keep monitoring config in sync with the currently activated license key.","Detect 404 from health as terminal for that key rather than retrying forever.","Re-check the license/subscription exists after billing changes."],"tags":["license","health-check","not-found","self-hosted"],"backgroundTag":"license-key-not-found","analyzedSha":"b4c8548c09da21b2898443559a5b846f0ccf5dd8","analyzedAt":"2026-08-18T21:16:52.546Z","contentChangedAt":"2026-08-18T21:16:52.546Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}