Skip to content

fix(general): Improve error handling to surface the most relevant error#6728

Merged
PeterSchafer merged 2 commits intomainfrom
fix/CLI-1455_error_priority
Apr 17, 2026
Merged

fix(general): Improve error handling to surface the most relevant error#6728
PeterSchafer merged 2 commits intomainfrom
fix/CLI-1455_error_priority

Conversation

@PeterSchafer
Copy link
Copy Markdown
Contributor

@PeterSchafer PeterSchafer commented Apr 15, 2026

Pull Request Submission Checklist

  • Follows CONTRIBUTING guidelines
  • Commit messages are release-note ready, emphasizing what was changed, not how.
  • Includes detailed description of changes
  • Contains risk assessment (Low | Medium | High)
  • Highlights breaking API changes (if applicable)
  • Links to automated tests covering new functionality
  • Includes manual testing instructions (if necessary)
  • Updates relevant GitBook documentation (PR link: ___)
  • Includes product update to be announced in the next stable release notes

What does this PR do?

Implements a first iteration error prioritization to ensure the most relevant/severe error is displayed and used for exit code derivation when multiple errors occur during CLI execution.

Changes:

  • Added FindMostRelevantError() function that finds the most relevant error from a list based on:
  • Updated error processing to use FindMostRelevantError() for selecting which error to display and derive exit codes from
  • Moved and extended maintenance error tests to a dedicated test file

Where should the reviewer start?

  1. Core logic for FindMostRelevantError() and priority comparison in the CLI errors package
  2. Usage in the processError() function
  3. Unit tests covering various scenarios

How should this be manually tested?

TEST_SNYK_COMMAND=binary-releases/snyk-macos-arm64 npx jest test/jest/acceptance/maintenance.spec.ts

@PeterSchafer PeterSchafer requested review from a team as code owners April 15, 2026 15:22
@snyk-io
Copy link
Copy Markdown

snyk-io Bot commented Apr 15, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@snyk-pr-review-bot

This comment has been minimized.

@PeterSchafer PeterSchafer force-pushed the fix/CLI-1455_error_priority branch 3 times, most recently from bfa4b5d to 6d3b8d2 Compare April 15, 2026 16:40
@snyk-pr-review-bot

This comment has been minimized.

@PeterSchafer PeterSchafer force-pushed the fix/CLI-1455_error_priority branch from 6d3b8d2 to 0e01700 Compare April 15, 2026 16:52
@snyk-pr-review-bot

This comment has been minimized.

@snyk-pr-review-bot

This comment has been minimized.

@snyk-pr-review-bot

This comment has been minimized.

@PeterSchafer PeterSchafer force-pushed the fix/CLI-1455_error_priority branch from ea58212 to 6264ed5 Compare April 16, 2026 07:19
@snyk-pr-review-bot

This comment has been minimized.

@PeterSchafer PeterSchafer force-pushed the fix/CLI-1455_error_priority branch from 6264ed5 to d00b96c Compare April 16, 2026 08:04
@snyk-pr-review-bot

This comment has been minimized.

@PeterSchafer PeterSchafer force-pushed the fix/CLI-1455_error_priority branch 2 times, most recently from 62e3bbd to 4ad557b Compare April 16, 2026 09:29
@snyk-pr-review-bot

This comment has been minimized.

@snyk-pr-review-bot

This comment has been minimized.

@PeterSchafer PeterSchafer force-pushed the fix/CLI-1455_error_priority branch from 4ad557b to 947e730 Compare April 16, 2026 10:58
@snyk-pr-review-bot

This comment has been minimized.

Comment thread cliv2/internal/errors/errors.go Outdated
Comment thread cliv2/internal/errors/errors.go
Comment thread cliv2/internal/errors/errors.go Outdated
@PeterSchafer PeterSchafer force-pushed the fix/CLI-1455_error_priority branch from 947e730 to 3146952 Compare April 16, 2026 12:48
@snyk-pr-review-bot

This comment has been minimized.

@PeterSchafer PeterSchafer force-pushed the fix/CLI-1455_error_priority branch from 3146952 to 09bc4e4 Compare April 16, 2026 13:04
@snyk-pr-review-bot

This comment has been minimized.

Comment thread cliv2/cmd/cliv2/main.go
@PeterSchafer PeterSchafer force-pushed the fix/CLI-1455_error_priority branch from 09bc4e4 to d58b48e Compare April 16, 2026 13:53
@snyk-pr-review-bot

This comment has been minimized.

@PeterSchafer PeterSchafer force-pushed the fix/CLI-1455_error_priority branch from d58b48e to 107b6bc Compare April 16, 2026 14:04
@snyk-pr-review-bot

This comment has been minimized.

@PeterSchafer PeterSchafer force-pushed the fix/CLI-1455_error_priority branch from 107b6bc to aea9438 Compare April 16, 2026 14:24
@snyk-pr-review-bot

This comment has been minimized.

@PeterSchafer PeterSchafer force-pushed the fix/CLI-1455_error_priority branch from aea9438 to 702a565 Compare April 16, 2026 15:11
@snyk-pr-review-bot

This comment has been minimized.

@PeterSchafer PeterSchafer force-pushed the fix/CLI-1455_error_priority branch from 702a565 to 85d7516 Compare April 16, 2026 15:35
@snyk-pr-review-bot

This comment has been minimized.

@PeterSchafer PeterSchafer enabled auto-merge April 16, 2026 15:37
@PeterSchafer PeterSchafer disabled auto-merge April 16, 2026 15:49
@PeterSchafer PeterSchafer force-pushed the fix/CLI-1455_error_priority branch from 85d7516 to 6369ff1 Compare April 16, 2026 15:53
@PeterSchafer PeterSchafer enabled auto-merge April 16, 2026 15:54
@snyk-pr-review-bot

This comment has been minimized.

@PeterSchafer PeterSchafer force-pushed the fix/CLI-1455_error_priority branch from 6369ff1 to 3070902 Compare April 16, 2026 16:33
@snyk-pr-review-bot

This comment has been minimized.

@snyk-pr-review-bot
Copy link
Copy Markdown

PR Reviewer Guide 🔍

🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Reduced Test Coverage 🟡 [minor]

The test case 'test a single file' in the Snyk Code user journey has been disabled using it.skip. While this might be intended to stabilize CI, it removes verification for a common user workflow (scanning a specific file) and should be addressed or documented as a known issue.

it.skip('test a single file', async () => {
📚 Repository Context Analyzed

This review considered 20 relevant code sections from 12 files (average relevance: 0.96)

@github-actions
Copy link
Copy Markdown
Contributor

Warnings
⚠️

Since the CLI is unifying on a standard and improved tooling, we're starting to migrate old-style imports and exports to ES6 ones.
A file you've modified is using either module.exports or require(). If you can, please update them to ES6 import syntax and export syntax.
Files found:

  • test/jest/acceptance/snyk-code/snyk-code-user-journey.spec.ts
⚠️ There are multiple commits on your branch, please squash them locally before merging!

Generated by 🚫 dangerJS against 30d60bf

@PeterSchafer PeterSchafer merged commit 298d4e1 into main Apr 17, 2026
9 checks passed
@PeterSchafer PeterSchafer deleted the fix/CLI-1455_error_priority branch April 17, 2026 07:38
mihaibuzgau added a commit that referenced this pull request Apr 21, 2026
fix(general): Improve error handling to surface the most relevant error
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