Skip to content

fix: correct license check to use data.valid instead of data.status in API v2#28521

Open
Harshithk951 wants to merge 2 commits intocalcom:mainfrom
Harshithk951:fix/license-check-valid-field-v2
Open

fix: correct license check to use data.valid instead of data.status in API v2#28521
Harshithk951 wants to merge 2 commits intocalcom:mainfrom
Harshithk951:fix/license-check-valid-field-v2

Conversation

@Harshithk951
Copy link
Contributor

What does this PR do?

Fixes #26610

The checkLicense() method in deployments.service.ts was checking
data.status to validate the license key, but the Cal.com license API
returns data.valid (not data.status). This caused all API v2
requests to fail with "Invalid or missing CALCOM_LICENSE_KEY" even
when a valid license key was set.

Visual Demo (For contributors especially)

N/A — single property name fix, no UI changes.

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. N/A
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

  1. Set a valid CALCOM_LICENSE_KEY in your environment
  2. Make any API v2 request that requires a license check
  3. Before fix: request fails with "Invalid or missing CALCOM_LICENSE_KEY"
  4. After fix: request succeeds as expected

No new environment variables required.

Checklist

  • I have read the contributing guide
  • My code follows the style guidelines of this project
  • My changes generate no new warnings
  • This PR is small (1 file, 3 lines changed)

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/api/v2/src/modules/deployments/deployments.service.ts">

<violation number="1" location="apps/api/v2/src/modules/deployments/deployments.service.ts:45">
P2: License check fallback is only applied on fresh fetch responses; cached responses still read only `valid`, so legacy cached `{status: true}` payloads bypass the fix.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

const cacheKey = getLicenseCacheKey(licenseKey);
this.redisService.redis.set(cacheKey, JSON.stringify(data), "EX", CACHING_TIME);
return data.status;
return data.valid ?? data.status ?? false;
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Mar 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: License check fallback is only applied on fresh fetch responses; cached responses still read only valid, so legacy cached {status: true} payloads bypass the fix.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/api/v2/src/modules/deployments/deployments.service.ts, line 45:

<comment>License check fallback is only applied on fresh fetch responses; cached responses still read only `valid`, so legacy cached `{status: true}` payloads bypass the fix.</comment>

<file context>
@@ -42,6 +42,6 @@ export class DeploymentsService {
     const cacheKey = getLicenseCacheKey(licenseKey);
     this.redisService.redis.set(cacheKey, JSON.stringify(data), "EX", CACHING_TIME);
-    return data.valid;
+    return data.valid ?? data.status ?? false;
   }
 }
</file context>
Fix with Cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛 bug Something isn't working size/XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[API v2] License validation bug: checkLicense checks data.status but API returns data.valid

1 participant