toeverything/AFFiNE · error · LicenseNotFound
license_not_found
license_not_found
Error message
License not found.
What it means
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).
Source
Thrown at packages/backend/server/src/plugins/payment/license/controller.ts:150
@Get('/:license/health')
async health(
@Res() res: Response,
@Param('license') key: string,
@Headers('x-validate-key') revalidateKey: string
) {
const license = await this.db.license.findUnique({
where: {
key,
},
});
const subscription = await this.manager.getActiveSubscription({
key,
plan: SubscriptionPlan.SelfHostedTeam,
});
if (!license || !subscription) {
throw new LicenseNotFound();
}
if (!license.validateKey || license.validateKey !== revalidateKey) {
throw new InvalidLicenseToActivate({
reason: 'Invalid validate key',
});
}
const validateKey = randomUUID();
await this.db.license.update({
where: {
key,
},
data: {
validateKey,
},
});
View on GitHub (pinned to b4c8548c09)
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.
Defensive patterns
Strategy: try-catch
Try / catch
const res = await fetch(`/api/team/licenses/${key}/health`, { headers: { 'x-validate-key': storedKey } });
if (res.status === 404) {
// LicenseNotFound: stop monitoring this key, re-activate a valid license
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Monitoring scripts retaining an old license key after renewal/change; billing-side subscription removal; DB restored from backup missing license rows.
Related errors
- license_not_found
- bad_request
- license_expired
- invalid_license_to_activate
- workspace_license_already_exists
AI-assisted analysis of toeverything/AFFiNE@b4c8548c09 (2026-08-18).
Data as JSON: /api/errors/367ede5379a47699.
Report an issue: GitHub.