GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Actionabilize errors from incorrect settings files by travisclagrone · Pull Request #1263 · PowerShell/PSScriptAnalyzer

Conversation

@travisclagrone

@travisclagrone Travis C. LaGrone (travisclagrone) commented Jun 18, 2019 •
edited by bergmeister
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Fixes #1053 "Errors from incorrect settings files are not actionable".

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bergmeister reacted with hooray emoji
All reactions
  • 🎉 1 reaction
@travisclagrone Travis C. LaGrone (travisclagrone) changed the title Revert "Annotatively research current state of exception handling surrounding settings file load invocation" Actionabilize errors from incorrect settings files Jun 18, 2019
@travisclagrone

Travis C. LaGrone (travisclagrone) commented Jun 18, 2019

Copy link
Copy Markdown
Contributor Author

The first commit adds only research comments, and the last commit reverts them. However, I have chosen to leave the commits in for documentary purposes in the history. In particular, I imagine that further work either refactoring or extending this code region might benefit from them.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bergmeister
Christoph Bergmeister (bergmeister) reviewed Jun 18, 2019
View reviewed changes

@bergmeister Christoph Bergmeister (bergmeister) left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

First of all thanks for making the effort and improvement. I agree that throwing a terminating error here is the right decision. One minor comment but hold off from addressing it at the moment, I will add more reviewers so that they can decide as well. But otherwise, it looks good to me. In the future we might enhance it to emit DiagnosticRecords of type ParserError in lower levels so that people get highlighting in VS Code but your change to improve the command line experience is good as a first improvement.
The red Ubuntu build can be ignored for the moment, this is a problem with the recent image update in AppVeyor that is also affecting the main development branch.
With the recently merged PR #1250, which improves the exceptions that are reported, this gives us now nice messages like this James Truher (@JamesWTruher) :-)

Invoke-ScriptAnalyzer -ScriptDefinition gci  -Settings @{foo='bar'}
Invoke-ScriptAnalyzer : foo is not a valid key in the settings hashtable. Valid keys are ExcludeRules, IncludeRules and Severity.
At line:1 char:2
+  Invoke-ScriptAnalyzer -ScriptDefinition gci  -Settings @{foo='bar'}
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : InvalidData: (System.Collections.Hashtable:Hashtable) [Invoke-ScriptAnalyzer], InvalidDataException
+ FullyQualifiedErrorId : InvalidSettingsData,Microsoft.Windows.PowerShell.ScriptAnalyzer.Commands.InvokeScriptAnalyzerCommand

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

rjmholt reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread Engine/Commands/InvokeScriptAnalyzerCommand.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

@bergmeister
Christoph Bergmeister (bergmeister) requested review from James Truher (JamesWTruher) and Rob Holt (rjmholt) June 18, 2019 12:41
@bergmeister Christoph Bergmeister (bergmeister) added the Area - Engine label Jun 18, 2019
@bergmeister
Christoph Bergmeister (bergmeister) changed the base branch from development to master June 18, 2019 21:11
rjmholt
Rob Holt (rjmholt) approved these changes Jun 19, 2019
View reviewed changes

@rjmholt Rob Holt (rjmholt) left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I think James Truher (@JamesWTruher) was working on something in this space as well.

Ideally this should actually throw an AggregateException and tell you all of the configuration problems (that's the general pattern for a parser, so you can fix as much as possible).

But I think this is a step in the right direction.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@rjmholt

Rob Holt (rjmholt) commented Jun 19, 2019

Copy link
Copy Markdown
Contributor

Christoph Bergmeister (@bergmeister) agreed re integration for other contexts; ideally rather than a parse error the error should be something PSES can catch and then display as a notification. We should discuss what the best design is there, especially in terms of revising the hosting model (James Truher (@JamesWTruher))

bergmeister reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bergmeister
Christoph Bergmeister (bergmeister) approved these changes Jun 22, 2019
View reviewed changes

@bergmeister Christoph Bergmeister (bergmeister) left a comment

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thanks, looks good to me, just one minor cleanup nit

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Engine/Commands/InvokeScriptAnalyzerCommand.cs Outdated
using System.Collections.ObjectModel;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;

@bergmeister Christoph Bergmeister (bergmeister) Jun 22, 2019

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Nit: With the last commit, this using statement is not needed any more.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@travisclagrone Travis C. LaGrone (travisclagrone) Jun 23, 2019

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

using System.IO; does appear to be required for pre-existing unqualified references to the type System.IO.InvalidDataException.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@bergmeister Christoph Bergmeister (bergmeister) Jun 29, 2019

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Not any more after the last commit that removed this type. I pushed a last commit to fix this and do some minor cleanup and make the format consistent to the solution and merge then after this.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Travis C. LaGrone (travisclagrone) added 6 commits June 22, 2019 19:34
@travisclagrone
Annotatively research current state of exception handling surrounding…
f8f8083
… settings file load invocation
@travisclagrone
Throw a contextful terminating error if processing the argument of 'I…
b75dced
…nvoke-ScriptAnalyzer -Settings' results in an exception
@travisclagrone
Refine id and category of error for when processing value of `Invoke-…
6648344
…ScriptAnalyzer -Settings` results in an exception
@travisclagrone
Revert "Annotatively research current state of exception handling sur…
0472359
…rounding settings file load invocation"

This reverts commit 3bfd45b.
@travisclagrone
Do not attempt id and category inference for the error to throw when …
a012dec
…processing the argument of `Invoke-ScriptAnalyzer -Settings` results in an exception
@travisclagrone
Remove using System.IO
88ab1ec
@travisclagrone
Travis C. LaGrone (travisclagrone) force-pushed the actionabilize-settings-file-errors branch from 1fc5c77 to 88ab1ec Compare June 23, 2019 00:35
@travisclagrone
Revert "Remove using System.IO"
2faab31
This reverts commit 88ab1ec.

`using System.IO` is required in Engine\Settings.cs after all. The main
use is for pre-existing unqualified references to the type
InvalidDataException.
@travisclagrone Travis C. LaGrone (travisclagrone) mentioned this pull request Jun 25, 2019
Aggregate exceptions when parsing a settings hashtable #1275
Closed
@bergmeister
Remove unused using after refactoring. Use more descriptive variable …
7bb07d5
…name and make error record arguments consistent with usage in other parts of the solution.
@bergmeister
Christoph Bergmeister (bergmeister) merged commit b407e8e into PowerShell:master Jun 29, 2019
@travisclagrone
Travis C. LaGrone (travisclagrone) deleted the actionabilize-settings-file-errors branch June 29, 2019 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@bergmeister Christoph Bergmeister (bergmeister) bergmeister approved these changes
@JamesWTruher James Truher (JamesWTruher) Awaiting requested review from JamesWTruher
+1 more reviewer
@rjmholt Rob Holt (rjmholt) rjmholt approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

Area - Engine

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Errors from incorrect settings files are not actionable

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@travisclagrone @rjmholt @bergmeister
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.