Skip to content

CODEFIX-1426 Interactively list and assign issues to Remediation Agent#239

Open
vnaskos-sonar wants to merge 6 commits intomasterfrom
vn/remediate-command
Open

CODEFIX-1426 Interactively list and assign issues to Remediation Agent#239
vnaskos-sonar wants to merge 6 commits intomasterfrom
vn/remediate-command

Conversation

@vnaskos-sonar
Copy link
Copy Markdown
Contributor

No description provided.

@hashicorp-vault-sonar-prod
Copy link
Copy Markdown

hashicorp-vault-sonar-prod Bot commented May 1, 2026

CODEFIX-1426

@vnaskos-sonar vnaskos-sonar force-pushed the vn/remediate-command branch 2 times, most recently from c146db0 to 0a5902b Compare May 5, 2026 14:13
@vnaskos-sonar vnaskos-sonar marked this pull request as ready for review May 5, 2026 14:52
Copy link
Copy Markdown
Contributor

@sonar-review-alpha sonar-review-alpha Bot left a comment

Choose a reason for hiding this comment

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

Solid implementation overall with good test coverage, but there are two bugs that need fixing before merge.

🗣️ Give feedback

Comment thread src/sonarqube/client.ts Outdated
Comment thread src/sonarqube/client.ts Outdated
Comment on lines +166 to +179
async function fetchEligibleIssues(
issuesClient: IssuesClient,
orgKey: string | undefined,
projectKey: string,
): Promise<SonarQubeIssue[]> {
const result = await issuesClient.searchIssues({
projects: projectKey,
organization: orgKey,
issueStatuses: 'OPEN,CONFIRMED',
fixableByAgent: true,
ps: MAX_PAGE_SIZE,
p: 1,
});
return result.issues;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Missing test coverage: fetchEligibleIssues fetches only page 1 (p: 1, ps: MAX_PAGE_SIZE = 500). For a project with more than 500 agent-fixable issues the remaining issues are silently omitted — the user sees "500 eligible issues found" with no indication that the list is truncated. No test covers this truncation scenario.

Either add pagination or document the cap and emit a warning when issues.length === MAX_PAGE_SIZE.

  • Mark as noise

@vnaskos-sonar vnaskos-sonar force-pushed the vn/remediate-command branch from 0a5902b to a77a508 Compare May 6, 2026 11:58
@sonar-review-alpha
Copy link
Copy Markdown
Contributor

sonar-review-alpha Bot commented May 6, 2026

Summary

This PR adds a new sonar remediate command that enables users to interactively select and submit eligible issues to the SonarQube Cloud Remediation Agent for AI-powered fixes.

What's new:

  • Interactive multi-select UI for choosing issues to remediate (sorted by severity, with color-coded display)
  • Validation that the organization has AI remediation entitlements enabled
  • Automatic project key discovery with --project override option
  • Clear error messages guiding users to documentation when feature is unavailable
  • Real-time feedback on job submission with a link to track progress in SonarQube Cloud

Implementation details:

  • Only works on SonarQube Cloud (rejects on-premise connections)
  • Fetches eligible issues in one page to avoid overwhelming users
  • Supports both project ID and key formats
  • Comprehensive error handling for entitlement and API failures

What reviewers should know

Start with the command implementation:

  • src/cli/commands/remediate/index.ts (215 lines) — the core logic. Key functions: remediate() (main flow), fetchEligibleIssues() (API call), formatIssueLabel() (UI formatting), mapErrorMessage() (error handling)

Review the tests next:

  • tests/integration/specs/remediate/remediate.test.ts (508 lines) — comprehensive coverage of happy path, entitlement checks, auth validation, error scenarios

Quick checklist for reviewers:

  • The command correctly validates Cloud-only usage (line 52)
  • Entitlement statuses (not_eligible, not_enabled, unknown) map to appropriate error messages
  • Issue sorting by severity (BLOCKER → CRITICAL → MAJOR → MINOR → INFO) makes high-priority issues easy to find
  • The job submission payload includes triggerSource: 'CLI' for tracking
  • Project key discovery (lines 84–93) handles both explicit --project and auto-detection cases
  • Error messages include the docs URL for user guidance
  • One-page fetch (line 183 comment) is intentional to avoid UX overload

Watch for:

  • The SonarQube API client's getComponentId() method (line 136) — returns component ID if available, falls back to key. Verify this behavior matches the agent API expectations.

  • Generate Walkthrough
  • Generate Diagram

🗣️ Give feedback

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor

@sonar-review-alpha sonar-review-alpha Bot left a comment

Choose a reason for hiding this comment

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

Two of the three previously flagged issues are resolved. The truncation concern at index.ts:185 is still open — fetchEligibleIssues caps silently at 500 issues with no user-facing warning, and no test covers that boundary.

🗣️ Give feedback

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.

1 participant