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

Displaying a friendlier error for unknown fields found in configuration files #2262

Merged
merged 16 commits into from
Sep 19, 2024

Conversation

marcosnav
Copy link
Collaborator

@marcosnav marcosnav commented Sep 5, 2024

Intent

In order to have more standardized errors handling, this PR introduces error types - to be expanded as we add more "known" errors.

Screenshot
Screen Shot 2024-09-17 at 10 56 53

Fixes #2157

Type of Change

Improvement

Approach

On the vscode extension UI code, changes made to getSummaryStringFromError allow to get a human consumable error message when the error contains a known JSON agent response - otherwise, a tracing-style message is returned to help diagnose.

Automated Tests

  • Updated backend tests as needed.
  • Added new UI tests for the new code. (Run locally and will add something to test on CI too)

Directions for Reviewers

  • Edit the active configuration and add an invalid entry (such as abc = 123).
  • Save the file.
  • Notice the error displayed in the notification.

Checklist

.github/CODEOWNERS Outdated Show resolved Hide resolved
Copy link
Collaborator

@sagerb sagerb left a comment

Choose a reason for hiding this comment

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

Had a few questions which might take these changes in the direction that the team had previously discussed. (Sorry, prior to your time.)

See what you think about my comments and let me know what questions you might have.

extensions/vscode/src/utils/errors.ts Outdated Show resolved Hide resolved
extensions/vscode/src/views/homeView.ts Outdated Show resolved Hide resolved
extensions/vscode/src/views/homeView.ts Outdated Show resolved Hide resolved
internal/services/api/api_helpers.go Outdated Show resolved Hide resolved
internal/services/api/get_config_files.go Outdated Show resolved Hide resolved
internal/util/toml.go Outdated Show resolved Hide resolved
@marcosnav
Copy link
Collaborator Author

@sagerb @mmarchetti Thanks for the feedback 🙇 I'll move some things around and re-request review when it is ready for a second look

@marcosnav
Copy link
Collaborator Author

@sagerb @mmarchetti This PR is ready for another look 🙂

Copy link
Collaborator

@sagerb sagerb left a comment

Choose a reason for hiding this comment

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

Going to reach out and move this to a verbal conversation. Then will update.

internal/publish/publish.go Outdated Show resolved Hide resolved
extensions/vscode/src/utils/errors.ts Outdated Show resolved Hide resolved
Copy link
Collaborator

@sagerb sagerb left a comment

Choose a reason for hiding this comment

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

I hate leaving the technical debt on the table for the suggestion I asked about, but if its not a fast change for you, I'm OK with merging without the change (and creating an issue to do it after the release).

// TODO: It would be better to have the config package methods as a provider pattern instead of plain functions
var configFromFile cfgFromFile = config.FromFile
var configGetConfigPath cfgGetConfigPath = config.GetConfigPath

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a reason we need to wait to make the change you indicated as a TODO?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't like leaving TODO's like this but in this case the suggested change would have an impact on many other places using the config package. That would expand this PR changes and also delay it's landing.

Copy link
Collaborator

@dotNomad dotNomad left a comment

Choose a reason for hiding this comment

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

I just had two questions pop up.

extensions/vscode/tsconfig.json Outdated Show resolved Hide resolved
}

func (apierr *APIErrorInvalidTOMLFileDetails) JSONResponse(w http.ResponseWriter) {
w.Header().Set("content-type", "application/json")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Saw the creation of JsonResult and noticed it wasn't used in this file. Just curious if that was intentional. It looks like JsonResult is only used once - should we consolidate into using it or leave this type of writer method calling?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Got it, yes this can be confusing. There is a small difference between them though, but it can be handled better.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Fantastic work on this file. Great exports, great helpers 💯

…nd rules. Include a resolution for rollup/parseAst
@marcosnav
Copy link
Collaborator Author

@dotNomad pushed a couple commits related to your questions. Things seem to be better now:

  • test files evaluated by TS compiler
  • Adjusted JsonResult to receive status and be used thoroughly

Copy link
Collaborator

@dotNomad dotNomad left a comment

Choose a reason for hiding this comment

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

Thanks for those additional changes @marcosnav! 🎉

@marcosnav marcosnav merged commit 0b783b9 into main Sep 19, 2024
13 checks passed
@marcosnav marcosnav deleted the config-err-friendly branch September 19, 2024 18:26
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.

Handle error displayed (500) when configuration is updated and becomes invalid
4 participants