CLI-693 Migrate CAG integration eligibility check to use the new entitlement endpoint#468
Conversation
…tlement endpoint
CAG setup in sonar integrate still queried the legacy cag-org-config endpoint and interpreted eligible/enabled flags when deciding whether to install Context Augmentation. That misses organizations whose access is now represented by the server-side CAG entitlement decision and also leaves the CLI warning tied to enablement-specific wording.
The mismatch happens at the CLI/backend boundary: the backend now owns GA entitlement, beta fallback, and temporary policy decisions behind a single allowed flag, while the CLI only needs to know whether setup should proceed.
This commit switches SonarQubeClient.hasCagEntitlement to /a3s-analysis/cag-entitlement/{uuid}, maps allowed/not_allowed/check_failed explicitly, and updates the shared Context Augmentation setup warning for denied access to mention eligible SonarQube Cloud plans. The shared helper continues to cover Claude, Copilot, Codex, and Antigravity without per-agent branching.
The fake SonarQube server and CAG setup tests now use the new allowed response shape, including an endpoint-failure path. The old internal enabled/not_enabled CAG status names were not kept because they no longer match the endpoint contract; SQAA and SCA status naming remains unchanged.
Validation: bun run format; bun test tests/unit/sonarqube/client.test.ts; bun test tests/integration/harness/fake-sonarqube-server.test.ts; bun run pretest:integration; bun run typecheck. The focused Context Augmentation integration spec could not be used locally because this machine has parent .git directories under temp roots, causing the harness to resolve the test project root outside its cwd.
|
This change is part of the following stack: Change managed by git-spice. |
✅ Deploy Preview for sonarqube-cli canceled.
|
Agentic Analysis: Early ResultsAgentic Analysis and Context Augmentation are available on your project. Here are some issues that could have been prevented. Follow the links to learn how to put them into action. 1 issue(s) found across 1 file(s):
Analyzed by SonarQube Agentic Analysis in 4.5 s |
|
Code Review ✅ Approved 1 resolved / 1 findingsMigrates the CAG integration eligibility check to the new entitlement endpoint and updates test mocks, resolving the untyped metadata error in the payload parser. ✅ 1 resolved✅ Bug: parseRequestPayloadTooLargeError passes untyped meta (TS error)
OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change:
Was this helpful? React with 👍 / 👎 | Gitar |



IMPORTANT: This PR depends on SonarSource/sonar-analysis-as-a-service#551. It should be merged only afterwards...
Use the new
/cag-entitlementendpoint instead of the obsolete/cag-org-configto perform entitlement checks. The old endpoint only handled the open-beta CAG access. The new endpoint handles both GA access and open-beta and provides a simpler interface that moves all the business logic to the server side. The PR also adjusts the warning message to make the failure more relevant to GA.The fake SonarQube server and CAG setup tests now use the new allowed response shape, including an endpoint-failure path. The old internal enabled/not_enabled CAG status names were not kept because they no longer match the endpoint contract; SQAA and SCA status naming remains unchanged.