NEW @W-22393677@ - User Not Logged In — Skip ApexGuru, Show Non-Blocking Connect Org Banner#360
NEW @W-22393677@ - User Not Logged In — Skip ApexGuru, Show Non-Blocking Connect Org Banner#360nikhil-mittal-165 wants to merge 1 commit into
Conversation
Extend Display interface to support buttons on displayInfo messages. Parse new insights field from CLI JSON output (backward compatible). Add InsightsHandler with session-level suppression per error.code. Show Connect Org / Retry Scan / Report Issue buttons based on error code. Wire Connect Org to trigger SF Core Extension auth or fallback message.
|
Git2Gus App is installed but the |
namrata111f
left a comment
There was a problem hiding this comment.
Comprehensive PR Review - PR #360
✅ Overall Assessment: APPROVE with minor recommendations
This PR implements a graceful handling mechanism for ApexGuru engine skips when users are not authenticated. The implementation is well-structured, thoroughly tested, and follows VSCode extension best practices.
Security Review ✅
Positive Security Aspects:
- No credential exposure - Error messages sanitized appropriately
- No command injection risks - All user interactions via VSCode API
- Secure external URL handling - GitHub issues URL hardcoded, not user-controlled
- Session-based suppression - Error code suppression stored in memory only (Set), no persistence
- Optional insights field - Backward compatible with older CLI versions (insights?: Record<string, EngineInsight>)
Security Recommendations:
- ✅ ISSUES_URL is hardcoded - good practice
- ✅ No eval/exec usage detected
- ✅ No workspace file writes without validation
Code Quality Review ✅
Architecture & Design:
- Well-separated concerns: InsightsHandler is a focused, single-responsibility class
- Dependency injection: Clean constructor injection pattern
- Type safety: Strong TypeScript typing with EngineInsight, ScanResults types
- Backward compatibility: Optional insights field supports older CLI versions
Implementation Highlights:
- Error code discrimination: Switch statement handles NO_ORG_CONNECTION, API_UNAVAILABLE, UNEXPECTED_ERROR
- Session suppression: Prevents banner spam via suppressedErrorCodes Set
- Retry mechanism: Callback pattern for retriggerScan maintains context
- Graceful degradation: Falls back to manual instructions if Core Extension unavailable
Code Quality Concerns:
MINOR: Line 280 has unused parameter prefix (_remediation) in handleUnexpectedError
- Consider logging remediation or remove if truly unused
MINOR: Display.displayInfo signature changed to accept buttons
- ✅ All call sites updated correctly in tests
- ✅ Backward compatible (buttons optional with ...buttons)
UI/UX Review ✅
VSCode UI Patterns:
- ✅ Non-blocking info banners - Correct choice for non-critical notifications
- ✅ Action buttons - "Connect Org", "Retry Scan", "View Details", "Report Issue"
- ✅ Output channel integration - windowManager.showLogOutputWindow() for details
- ✅ External link handling - windowManager.showExternalUrl() for issue reporting
User Experience:
- Progressive disclosure: Details hidden in log output, accessible via button
- Contextual actions:
- NO_ORG_CONNECTION → Connect Org button triggers sfdx.authorize.org
- API_UNAVAILABLE → Retry Scan + Details buttons
- UNEXPECTED_ERROR → View Details + Report Issue buttons
- Fallback messaging: If Core Extension unavailable, shows manual CLI command
UX Recommendations:
- ✅ Messages are user-friendly and actionable
- ✅ Session suppression prevents notification fatigue
- SUGGESTION: Consider adding telemetry for insight error rates to detect systemic issues
VSCode API Compatibility Review ✅
API Usage:
- ✅ vscode.window.showInformationMessage - Standard API, stable
- ✅ vscode.commands.executeCommand('sfdx.authorize.org') - Depends on Salesforce Core Extension
- ✅ No deprecated APIs detected
- ✅ Engine version: package.json specifies "vscode": "^1.90.0" (appropriate)
Dependency Check:
- ✅ No new external dependencies added
- ✅ Uses existing WindowManager abstraction for testability
Test Coverage Review ✅ EXCELLENT
Unit Test Coverage (test/lib/insights-handler.test.ts):
- ✅ 12 test cases covering all error codes and edge cases
- ✅ Session suppression verified
- ✅ Button callbacks tested
- ✅ Async fallback handling tested (Connect Org when Core Extension unavailable)
- ✅ Mock isolation - SpyDisplay, SpyLogger, StubExternalServiceProvider
Integration Test Coverage (test/lib/insights-handler.integration.test.ts):
- ✅ 7 test cases covering full lifecycle
- ✅ Backward compatibility - undefined insights field
- ✅ Retry scan flow - callback triggers re-run
- ✅ Banner suppression - cross-scan persistence
- ✅ Different error codes - independent suppression
Test Coverage Stats:
- 362/362 tests pass ✅
- 97.19% coverage ✅
- Integration baseline: dreamhouse scan 637 violations ✅
Test Quality Assessment:
EXCELLENT - Comprehensive unit + integration tests, edge cases covered
Documentation Review ✅
Code Documentation:
- ✅ JSDoc comments on public methods
- ✅ Type definitions (EngineInsight, ScanResults) self-documenting
- ✅ messages.ts contains user-facing strings (good i18n preparation)
PR Documentation:
- ✅ Clear summary in PR body
- ✅ Test evidence provided
- ✅ Dependency link to code-analyzer-core PR #478
- ✅ GUS ticket W-22393677 referenced
Documentation Recommendations:
- ✅ README.md not modified (appropriate - internal feature)
- SUGGESTION: Consider adding CHANGELOG entry for 1.21.0-SNAPSHOT
Additional Observations
Performance:
- ✅ Minimal overhead - handleInsights() early returns if no insights/apexguru
- ✅ No blocking operations on main thread
- ✅ Async operations (isOrgConnectionServiceAvailable, executeCommand) properly handled
Maintainability:
- ✅ Clear separation of concerns
- ✅ Extensible switch statement for future error codes
- ✅ Testable via dependency injection
Backward Compatibility:
- ✅ CRITICAL: insights field is optional (insights?: Record<string, EngineInsight>)
- ✅ Older CLI versions without insights field work correctly
- ✅ Extension compiles with both old and new CLI output formats
Final Recommendations
Required Changes: NONE ✅
Optional Improvements:
- MINOR: Remove or use _remediation parameter in handleUnexpectedError (line 280)
- SUGGESTION: Add telemetry for insight error tracking
- SUGGESTION: Consider CHANGELOG entry for version 1.21.0
Merge Readiness: ✅ READY TO MERGE
This PR is well-implemented, thoroughly tested, and follows all VSCode extension best practices. The graceful degradation and backward compatibility ensure a smooth rollout.
Review Confidence: HIGH
Recommendation: APPROVE
aruntyagiTutu
left a comment
There was a problem hiding this comment.
APPROVED — Meets Code Analyzer guidelines. Gracefully handles undefined ApexGuru insights when user not authenticated.
Review Against Guidelines ✅
3. Validation & Error Handling ✅
- InsightsHandler validates insights at boundary
- Distinct handling per error code (NO_ORG_CONNECTION, API_UNAVAILABLE, UNEXPECTED_ERROR)
- Non-blocking banner guides user to authenticate
4. Logging ✅
- Appropriate log levels used
5. Architecture ✅
- InsightsHandler properly separated
- Wired into CodeAnalyzerRunAction.run() at line 115
- ResultsJson type supports optional insights for backward compat
6. Testing ✅
- 362/362 tests pass (97.19% coverage)
- Integration baseline: dreamhouse scan 637 violations, no crash
- Feature-specific: CLI omits insights when SFAP not configured
- Mocked insights scenarios cover all error codes
8. PR Hygiene ✅
- Title follows convention: NEW @W-22393677@
- Depends on forcedotcom/code-analyzer-core#478 (already approved)
- Test evidence included
No blocking issues.
Summary
When a user is not logged in to a Salesforce org, the ApexGuru engine is skipped gracefully, and a non-blocking "Connect Org" banner is displayed to guide the user to authenticate.
GUS Ticket W-22393677 — User Not Logged In — Skip ApexGuru, Show Non-Blocking "Connect Org" Banner
Changes
Dependencies
Test Evidence
Unit tests: 362/362 pass (24 suites, 97.19% coverage). Integration baseline: dreamhouse scan 637 violations, no crash, CLI exit 0. Feature-specific: CLI correctly omits insights when SFAP not configured (AG engine returns 0 rules, graceful skip). VS Code extension handles undefined insights via optional field in ResultsJson type - backward compat confirmed by unit tests. InsightsHandler correctly wired into CodeAnalyzerRunAction.run() flow at line 115. No fixes needed.
Test Status
PASS
Fix attempts: 0
Integration: PASS - baseline scan succeeds (637 violations), CLI does not crash with AG absent, extension compiles and all unit tests pass with mocked insights scenarios covering all error codes
Known external failures (not blocking): ApexGuru engine disabled in test env (SFAP API base URL not configured) - cannot produce live insights output