Skip to content

CLI-693 Migrate CAG integration eligibility check to use the new entitlement endpoint#468

Merged
michael-jabbour-sonarsource merged 3 commits into
masterfrom
mj/CLI-693_CAG_entitlement
Jun 19, 2026
Merged

CLI-693 Migrate CAG integration eligibility check to use the new entitlement endpoint#468
michael-jabbour-sonarsource merged 3 commits into
masterfrom
mj/CLI-693_CAG_entitlement

Conversation

@michael-jabbour-sonarsource

@michael-jabbour-sonarsource michael-jabbour-sonarsource commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

IMPORTANT: This PR depends on SonarSource/sonar-analysis-as-a-service#551. It should be merged only afterwards...

Use the new /cag-entitlement endpoint instead of the obsolete /cag-org-config to 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.

…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.
@michael-jabbour-sonarsource

Copy link
Copy Markdown
Contributor Author

This change is part of the following stack:

Change managed by git-spice.

@netlify

netlify Bot commented Jun 17, 2026

Copy link
Copy Markdown

Deploy Preview for sonarqube-cli canceled.

Name Link
🔨 Latest commit d28d879
🔍 Latest deploy log https://app.netlify.com/projects/sonarqube-cli/deploys/6a353c23b9eca2000890db03

@sonarqubecloud

sonarqubecloud Bot commented Jun 17, 2026

Copy link
Copy Markdown

Agentic Analysis: Early Results

Agentic 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):

Rule File Line Message
typescript:S109 tests/integration/specs/integrate/context-augmentation.test.ts 381 No magic number: 500.

Analyzed by SonarQube Agentic Analysis in 4.5 s

@hashicorp-vault-sonar-prod

hashicorp-vault-sonar-prod Bot commented Jun 17, 2026

Copy link
Copy Markdown

CLI-693

@michael-jabbour-sonarsource michael-jabbour-sonarsource marked this pull request as ready for review June 17, 2026 13:34

@awegsche awegsche left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM

Comment thread CLAUDE.md
@sonarqubecloud

Copy link
Copy Markdown

@michael-jabbour-sonarsource michael-jabbour-sonarsource merged commit 4da4782 into master Jun 19, 2026
10 checks passed
@michael-jabbour-sonarsource michael-jabbour-sonarsource deleted the mj/CLI-693_CAG_entitlement branch June 19, 2026 12:55
@gitar-bot

gitar-bot Bot commented Jun 19, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 1 resolved / 1 findings

Migrates 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)

📄 src/sonarqube/client.ts:672 📄 src/sonarqube/client.ts:716-717
StructuredErrorBody.meta is widened to RequestPayloadTooLargeMeta | Record<string, unknown> (line 672), but parseRequestPayloadTooLargeError passes body.meta straight into the RequestPayloadTooLargeError constructor (lines 716-717), whose meta parameter is typed RequestPayloadTooLargeMeta | undefined. Under the project's strict TS config, Record<string, unknown> is not assignable to RequestPayloadTooLargeMeta, so this fails type checking. Note the sibling parseBadRequestError correctly casts (body.meta as Record<string, unknown> | undefined, line 701) — this function is missing the equivalent narrowing. Per the project rule "Fix all type errors before task completion," this will break the build.

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing less information.

Comment with these commands to change:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants