Skip to content

NEW @W-21910054@ Message sanitization - #2081

Merged
nikhil-mittal-165 merged 1 commit into
devfrom
message-sanitization
Aug 18, 2026
Merged

NEW @W-21910054@ Message sanitization#2081
nikhil-mittal-165 merged 1 commit into
devfrom
message-sanitization

Conversation

@nikhil-mittal-165

@nikhil-mittal-165 nikhil-mittal-165 commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Sanitizes the run command's org-authentication error path so that ApexGuru auth failures are handled consistently and gracefully instead of aborting the whole run with a generic SfError.

  • Removed RunAction.validateTargetOrg() / the upfront Org.create() pre-check. ApexGuru is the only engine that consumes --target-org, and ApexGuruAuthService/ApexGuruEngine (see code-analyzer-core#500) already produce a clear, actionable message and skip gracefully with a warning (NO_ORG_CONNECTION/INVALID_SESSION) rather than throwing. Keeping the CLI-level pre-check meant two divergent error messages for the same failure.
  • Behavior/exit-code change (intentional): as of this PR, running sf code-analyzer run --target-org <bad-or-unauthenticated-org> no longer fails the whole command. ApexGuru is skipped with a warning (visible in the terminal output/log) and the command otherwise completes normally (exit code reflects violations found by other engines, not the org-auth failure). This is a deliberate consequence of delegating auth handling to the engine layer, but it does change exit-code/CI semantics for existing scripts that relied on --target-org failing fast on a bad org — calling it out explicitly here since it isn't just a message-wording change.
  • Also bundles in ActionSummaryViewer.displayApexGuruAnalysisMode() (new run-action.apexguru-analysis-mode message), which prints ApexGuru analysis mode: ADVANCED/BASIC in the terminal summary when ApexGuru insights report an analysis mode. This is unrelated new functionality rather than sanitization — including it here rather than a separate PR since it's small, well-tested, and low-risk; flagging it explicitly per team convention so reviewers aren't surprised by scope.

Test plan

  • test/lib/actions/RunAction.test.ts updated: removed the two tests asserting the old throw-on-bad-org behavior (with a comment explaining why, and pointing to core's ApexGuruAuthService/ApexGuruEngine tests for that coverage), added coverage for the new ApexGuru analysis-mode summary line (fullADVANCED, staticBASIC, no line when absent/engine didn't run).
  • Unit tests, lint, and typecheck pass locally.

@aruntyagiTutu aruntyagiTutu left a comment

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.

The sanitization-motivated change is sound: removing RunAction.validateTargetOrg()/Org.create() pre-check makes sense once ApexGuruAuthService (code-analyzer-core#500) produces its own clear, actionable message and the engine skips gracefully with a warning instead of the CLI aborting the whole run with a generic SfError. That avoids two divergent error messages for the same failure and is well covered by the updated RunAction.test.ts (including the new comment explaining why the org-auth tests were removed).

One thing worth calling out since the PR description is empty (same pattern as sfdx-code-analyzer-vscode#368 and code-analyzer-core#500 from the same author): this PR also bundles in an unrelated feature — ActionSummaryViewer.displayApexGuruAnalysisMode() and the new run-action.apexguru-analysis-mode message, which prints ApexGuru analysis mode: ADVANCED/BASIC in the terminal summary. That's new user-facing functionality, not message sanitization, and per the team's "one concern per PR" convention it'd be cleaner as a separate PR. Not blocking since it's well-tested and low-risk, but worth a mention in the description (or splitting out) so reviewers aren't surprised by scope.

Also worth confirming: is it intentional that a bad/unauthenticated --target-org now causes the whole run command to succeed (ApexGuru skipped with a warning) rather than fail? That's a behavior change beyond message wording — likely the right call given ApexGuru is the only consumer of target-org, but since it changes exit-code/CI semantics for existing users of --target-org, it'd be good to state that explicitly in the PR description.

@nikhil-mittal-165

Copy link
Copy Markdown
Contributor Author

Thanks for the review!

Confirmed the exit-code behavior change is intentional: bad/unauthenticated --target-org no longer fails runApexGuruAuthService/ApexGuruEngine in code-analyzer-core#500 catch the auth failure and skip ApexGuru with a warning (NO_ORG_CONNECTION) rather than throwing, since ApexGuru is the only consumer of target-org. I've added an explicit note about this in the PR description so it's not just implied by the diff.

On the ApexGuru analysis-mode terminal summary: agreed it's a separate concern from sanitization. Given it's small, well-tested, and low-risk, I've kept it bundled here but called it out explicitly in the description per the "one concern per PR" convention, rather than splitting it into its own PR.

@nikhil-mittal-165
nikhil-mittal-165 merged commit f290d1a into dev Aug 18, 2026
21 checks passed
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.

2 participants