Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: display a unique interaction id alongside each error #5737

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

sandor-trombitas
Copy link
Contributor

@sandor-trombitas sandor-trombitas commented Feb 13, 2025

Pull Request Submission Checklist

  • Follows CONTRIBUTING guidelines
  • Includes detailed description of changes
  • Contains risk assessment (Low)
  • 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: ___)

What does this PR do?

Adds the interaction id to the rendered error when a scan fails

Where should the reviewer start?

review the changes in gaf

How should this be manually tested?

run a test that is expect to fail, eg:

Screenshots

Example of new general CLI failure Error Catalog output:


 ERROR   Unspecified Error (SNYK-CLI-0000)
         The encountered error only provides basic information, please take a look at   
         the given details.If they do not help to resolve the issue, consider debugging 
         or consulting support.                                                         
                                                                                        
           Must set `--format` flag to specify an SBOM format. Available formats are:     
           cyclonedx1.4+json, cyclonedx1.4+xml, cyclonedx1.5+json, cyclonedx1.5+xml,      
           cyclonedx1.6+json, cyclonedx1.6+xml, spdx2.3+json                              
Docs:    https://docs.snyk.io/scan-with-snyk/error-catalog#snyk-cli-0000 
         https://docs.snyk.io/snyk-cli/commands                          
         https://docs.snyk.io/snyk-cli/debugging-the-snyk-cli       

ID:  urn:snyk:interaction:<UUID>                                                              

Example of specific Error Catalog error output:


 ERROR   Authentication error (SNYK-0005)
         Authentication credentials not recognized, or user access is not provisioned.  
         Revise credentials and try again, or request access from your Snyk             
         administrator.                                                                 
                                                                                        
           Use `snyk auth` to authenticate.                                               
                          
Status:  401 Unauthorized                                                                    
Docs:    https://docs.snyk.io/scan-with-snyk/error-catalog#snyk-0005

ID:  urn:snyk:interaction:<UUID>                        

@sandor-trombitas sandor-trombitas requested a review from a team as a code owner February 13, 2025 14:36
@sandor-trombitas sandor-trombitas force-pushed the feat/CLI-680-interaction-id branch from 623f390 to 3e0391d Compare February 13, 2025 14:38
@sandor-trombitas sandor-trombitas force-pushed the feat/CLI-680-interaction-id branch 2 times, most recently from db34eeb to eb3adb3 Compare February 14, 2025 10:58
@sandor-trombitas sandor-trombitas changed the title feat/CLI 680 interaction id feat: cli-680 add interaction id Feb 14, 2025
@j-luong j-luong force-pushed the feat/CLI-680-interaction-id branch 9 times, most recently from 87142ac to 8274b3c Compare February 18, 2025 16:09
@thisislawatts thisislawatts force-pushed the feat/CLI-680-interaction-id branch 2 times, most recently from 2c06ec0 to 044d048 Compare February 19, 2025 15:42
@thisislawatts thisislawatts force-pushed the feat/CLI-680-interaction-id branch from 044d048 to e020277 Compare February 19, 2025 15:43
@PeterSchafer
Copy link
Collaborator

PeterSchafer commented Feb 19, 2025

The PR title says feat, the commit says chore. Let's settle on chore please! And add something meaningful.

@thisislawatts thisislawatts changed the title feat: cli-680 add interaction id chore: cli-680 add interaction id Feb 20, 2025
@thisislawatts thisislawatts changed the title chore: cli-680 add interaction id chore: display a unique interaction id alongside each error Feb 20, 2025
Copy link
Contributor

github-actions bot commented Feb 20, 2025

Warnings
⚠️ There are multiple commits on your branch, please squash them locally before merging!
⚠️

"chore(deps): upgrade go-application-framework@04faf47716bb0f1a05801823b7a851e33c6dbd5f" is too long. Keep the first line of your commit message under 72 characters.

⚠️

"chore: restore original assertions add in validation of metadata behaviour" is too long. Keep the first line of your commit message under 72 characters.

Generated by 🚫 dangerJS against 3314c9e

@thisislawatts thisislawatts force-pushed the feat/CLI-680-interaction-id branch 4 times, most recently from 7049390 to 8d4289a Compare February 20, 2025 16:50
@thisislawatts thisislawatts force-pushed the feat/CLI-680-interaction-id branch from 8d4289a to 355caa7 Compare February 20, 2025 16:54
@thisislawatts thisislawatts force-pushed the feat/CLI-680-interaction-id branch from 00068b1 to 008d6ad Compare February 21, 2025 09:24
uiError := userInterface.OutputError(err)
if uiError != nil {
globalLogger.Err(uiError).Msg("ui failed to show error")
}
userInterface.Output(fmt.Sprintf("\nID: %s", interactionId))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Question: Showing the a single InteractionId can also be achieved in OutputError() and would keep the concerns of presenting errors separated from the orchestration logic in main. Is there a reason not to adapt OutputError() so that it can also work for multiple errors at time point in the future?

Copy link
Collaborator

Choose a reason for hiding this comment

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

After syncing, we decided to wait for design input and then see what is the best way to continue.

@PeterSchafer
Copy link
Collaborator

Issue: I think the current changes lost a new line, for example when running snyk sbom --format cyclonedx1.4+json --file=./foldernotthere

ERROR   Unspecified Error (SNYK-CLI-0000)
         The encountered error only provides basic information, please take a look at
         the given details.If they do not help to resolve the issue, consider debugging
         or consulting support.

           An error occurred while running the underlying analysis needed to generate
           the SBOM.
Docs:    https://docs.snyk.io/scan-with-snyk/error-catalog#snyk-cli-0000
         https://docs.snyk.io/snyk-cli/commands
         https://docs.snyk.io/snyk-cli/debugging-the-snyk-cli

ID: urn:snyk:interaction:78ba05be-1f33-4432-b51e-786ee77939b7

Before docs there should be a separator.

@thisislawatts thisislawatts force-pushed the feat/CLI-680-interaction-id branch from b1b4a3e to dcbe9be Compare February 21, 2025 10:57
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.

4 participants