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: add errors to the end of debug logs [CLI-671] #5683

Conversation

j-luong
Copy link
Contributor

@j-luong j-luong commented Jan 23, 2025

Pull Request Submission Checklist

  • Follows CONTRIBUTING guidelines
  • 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: ___)

What does this PR do?

This PR should add error catalog errors to the end of debug logs to aide in diagnosing issues.

Some notes on implementation:

  • Only one of each ErrorCatalog.ErrorCode is output in the debug logs to prevent too much repetition
  • ErrorCatalog.Meta["details"] is created and used instead of ErrorCatalog.Detail. Its contents is deduped.
  • ErrorCatalog.Meta["request-id"] and ErrorCatalog.Meta["request-path"] are combined into ErrorCatalog.Meta["requests"] and used

Where should the reviewer start?

How should this be manually tested?

Run a command that results in an error catalog error, e.g.

  • SNYK_TOKEN=random ./binary-releases/snyk-<binary> test -d
  • INTERNAL_SNYK_CODE_IGNORES_ENABLED=true ./binary-releases/snyk-macos-arm64 code test ./emptyFolder -d
    A new footer section should appear at the end of the debug logs with the list of error catalog errors

Screenshots (if appropriate)

> SNYK_TOKEN=someToken INTERNAL_SNYK_CODE_IGNORES_ENABLED=true ./binary-releases/snyk-macos-arm64 code test ./emptyFolder -d
2025-01-27T17:34:01Z internal.cleanup:3 - Workflow End
2025-01-27T17:34:01Z main - Error (0):             SNYK-0005 (Authentication error)
2025-01-27T17:34:01Z main -   Type:                https://docs.snyk.io/scan-with-snyk/error-catalog#snyk-0005
2025-01-27T17:34:01Z main -   Classification:      ACTIONABLE
2025-01-27T17:34:01Z main -   Description:         Authentication credentials not recognized, or user access is not provisioned. Revise credentials and try again, or request access from your Snyk administrator.
2025-01-27T17:34:01Z main -   Details:             
2025-01-27T17:34:01Z main -     0:                 Use `snyk auth` to authenticate.
2025-01-27T17:34:01Z main -   Requests:            
2025-01-27T17:34:01Z main -     0:                 39c4fc66-9e0c-4cdc-8771-3283109d06dc - /rest/self
2025-01-27T17:34:01Z main -     1:                 48f2c0bb-46e5-4a7f-8a9c-23341a4073d2 - /rest/self
2025-01-27T17:34:01Z main -     2:                 bb2eb2d4-5647-4b18-99c3-011ff3fe0273 - /v1/cli-config/settings/sast
2025-01-27T17:34:01Z main -     3:                 bb2eb2d4-5647-4b18-99c3-011ff3fe0273 - /v1/cli-config/settings/sast
2025-01-27T17:34:01Z main -     4:                 bb2eb2d4-5647-4b18-99c3-011ff3fe0273 - /v1/cli-config/settings/sast
2025-01-27T17:34:01Z main -     5:                 0205d0d6-3bea-4e77-ba2f-ddce490e1f76 - /v1/analytics/cli
2025-01-27T17:34:01Z main -     6:                 fc58ccb3-e542-4c93-a053-ed36d53a824d - /rest/self
2025-01-27T17:34:01Z main - Exit Code:             2

When there are multiple Error Catalog errors in the errorsList:

2025-01-27T20:22:34Z internal.cleanup:6 - Workflow End
2025-01-27T20:22:34Z main - Error (0):             SNYK-CODE-0006 (Project not supported)
2025-01-27T20:22:34Z main -   Type:                https://docs.snyk.io/scan-with-snyk/error-catalog#snyk-code-0006
2025-01-27T20:22:34Z main -   Classification:      ACTIONABLE
2025-01-27T20:22:34Z main -   Description:         Snyk was unable to find supported files.
2025-01-27T20:22:34Z main -   Details:             
2025-01-27T20:22:34Z main -     0:                 Snyk was unable to find supported files.
2025-01-27T20:22:34Z main -   Links:               
2025-01-27T20:22:34Z main -     0:                 https://docs.snyk.io/getting-started/supported-languages-frameworks-and-feature-availability-overview#code-analysis-snyk-code
2025-01-27T20:22:34Z main - Error (1):             SNYK-CLI-0000 (Unspecified Error)
2025-01-27T20:22:34Z main -   Type:                https://docs.snyk.io/scan-with-snyk/error-catalog#snyk-cli-0000
2025-01-27T20:22:34Z main -   Classification:      UNEXPECTED
2025-01-27T20:22:34Z main -   Description:         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.
2025-01-27T20:22:34Z main -   Details:             
2025-01-27T20:22:34Z main -     0:                 something went wrong
2025-01-27T20:22:34Z main -     1:                 something different went wrong
2025-01-27T20:22:34Z main -   Links:               
2025-01-27T20:22:34Z main -     0:                 https://docs.snyk.io/snyk-cli/commands
2025-01-27T20:22:34Z main -     1:                 https://docs.snyk.io/snyk-cli/debugging-the-snyk-cli
2025-01-27T20:22:34Z main - Error (2):             SNYK-CLI-0001 (Unable to set environment)
2025-01-27T20:22:34Z main -   Type:                https://docs.snyk.io/scan-with-snyk/error-catalog#snyk-cli-0001
2025-01-27T20:22:34Z main -   Classification:      ACTIONABLE
2025-01-27T20:22:34Z main -   Description:         The specified environment cannot be used. As a result, the configuration remains unchanged.Provide the correct specifications for the environment and try again.
2025-01-27T20:22:34Z main -   Details:             
2025-01-27T20:22:34Z main -     0:                 oops
2025-01-27T20:22:34Z main -   Links:               
2025-01-27T20:22:34Z main -     0:                 https://docs.snyk.io/snyk-cli/commands/config-environment
2025-01-27T20:22:34Z main - Error (3):             SNYK-OS-7001 (Request to Snyk API timeout)
2025-01-27T20:22:34Z main -   Type:                https://docs.snyk.io/scan-with-snyk/error-catalog#snyk-os-7001
2025-01-27T20:22:34Z main -   Classification:      UNEXPECTED
2025-01-27T20:22:34Z main -   Description:         A request to the Snyk API has unexpectedly timeout. Check Snyk status, then try again.
2025-01-27T20:22:34Z main -   Details:             
2025-01-27T20:22:34Z main -     0:                 timeout
2025-01-27T20:22:34Z main -   Links:               
2025-01-27T20:22:34Z main -     0:                 https://status.snyk.io/
2025-01-27T20:22:34Z main - Exit Code:             3

@j-luong j-luong force-pushed the chore/CLI-671_addErrorCatalogErrorsToDebugLogs branch from 63d993a to 73d0c26 Compare January 24, 2025 10:25
@j-luong j-luong marked this pull request as ready for review January 24, 2025 10:28
@j-luong j-luong requested a review from a team as a code owner January 24, 2025 10:28
@j-luong j-luong force-pushed the chore/CLI-671_addErrorCatalogErrorsToDebugLogs branch 2 times, most recently from c8467b2 to 2bac2dc Compare January 24, 2025 11:21
@PeterSchafer
Copy link
Collaborator

PeterSchafer commented Jan 27, 2025

Suggestion: Let's improve the information presentation to make it better digestible. For example like this.

2025-01-24T10:26:01Z main - Error (1):             SNYK-0005 (Authentication error)
2025-01-24T10:26:01Z main -   classification:      ACTIONABLE
2025-01-24T10:26:01Z main -   description:         Authentication credentials not recognized, or user access is not provisioned. Revise credentials and try again, or request access from your Snyk administrator.
2025-01-24T10:26:01Z main -                        Use `snyk auth` to authenticate.
2025-01-24T10:26:01Z main -   type:                https://docs.snyk.io/scan-with-snyk/error-catalog#snyk-0005
2025-01-24T10:26:01Z main -   request-id:
2025-01-24T10:26:01Z main -     0                  049c7adb-8051-48e7-a664-6a305acb065d /rest/self
2025-01-24T10:26:01Z main -     1                  049c7adb-8051-48e7-a664-6a305acb065d /rest/self
2025-01-24T10:26:01Z main - Error (2):             SNYK-0007 (das)
2025-01-24T10:26:01Z main -   classification:      ACTIONABLE
2025-01-24T10:26:01Z main -   description:         Authentication credentials not recognized, or user access is not provisioned. Revise credentials and try again, or request access from your Snyk administrator.
2025-01-24T10:26:01Z main -                        Use `snyk auth` to authenticate.
2025-01-24T10:26:01Z main -   type:                https://docs.snyk.io/scan-with-snyk/error-catalog#snyk-0005
2025-01-24T10:26:01Z main -   request-id:
2025-01-24T10:26:01Z main -     0                  049c7adb-8051-48e7-a664-6a305acb065d /rest/self
2025-01-24T10:26:01Z main -     1                  049c7adb-8051-48e7-a664-6a305acb065d /rest/self
2025-01-24T10:26:01Z main - Exit Code:             2


@j-luong j-luong force-pushed the chore/CLI-671_addErrorCatalogErrorsToDebugLogs branch 2 times, most recently from acc67fc to eaf2ccf Compare January 27, 2025 15:01
@j-luong j-luong force-pushed the chore/CLI-671_addErrorCatalogErrorsToDebugLogs branch 3 times, most recently from c8d6a40 to 2e6a398 Compare January 28, 2025 09:35
@j-luong j-luong force-pushed the chore/CLI-671_addErrorCatalogErrorsToDebugLogs branch 2 times, most recently from aa88bcf to ba6a55d Compare January 28, 2025 12:07
@j-luong j-luong force-pushed the chore/CLI-671_addErrorCatalogErrorsToDebugLogs branch from ba6a55d to ba33944 Compare January 28, 2025 15:34
@j-luong j-luong changed the base branch from main to feat/passing-ts-errors-to-go January 28, 2025 15:36
Copy link
Contributor

@sandor-trombitas sandor-trombitas left a comment

Choose a reason for hiding this comment

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

👍

@j-luong j-luong merged commit 5d0f0c9 into feat/passing-ts-errors-to-go Jan 28, 2025
7 checks passed
@j-luong j-luong deleted the chore/CLI-671_addErrorCatalogErrorsToDebugLogs branch January 28, 2025 16:35
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.

5 participants