-
Type:
Bug
-
Status: Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: PowerShell 2.0.3
-
Component/s: powershell, windows
-
Labels:None
-
Template:customfield_10700 135417
-
Acceptance Criteria:
- Error messages should clearly identify user code is at fault, and not the module
- There should be a new test to demonstrate this behavior
-
Epic Link:
-
Story Points:2
-
Sprint:Windows 2016-09-07
The puppet-chocolatey community module uses reflection to modify the current PowerShell host. However, it was a bit fragile, generated exceptions, and propagated them through PowerShell module 2.0.
While the fix was put in at https://github.com/chocolatey/puppet-chocolatey/commit/166ae968dd455a9cf94cf3d88050f9a973c449ce, this still raises an interesting issue for executing user code.
Our code should be a little more defensive / explanatory, when the call to EndInvoke over user code is executed. As it stood, the error message generated was a bit misleading:
Debug: STDERR: Exception calling "EndInvoke" with "1" argument(s): "You cannot call a method on a null-valued expression."
The exception was thrown from:
https://github.com/puppetlabs/puppetlabs-powershell/blob/a0f3cc7498730df9ccde98c1bea40920b0a3643a/lib/puppet_x/templates/invoke_ps_command.erb#L428
The module can do a better job of identifying the problem is with user code (which may involve parsing the exceptions, etc).
This might also be a good time to do a simple cleanup of the repetitive $ps.Commands.Clear() calls that showed up in https://github.com/puppetlabs/puppetlabs-powershell/commit/9b785f0c149d59b7a91f1efb48f0bc8235f031c9 - these seem unnecessary, and the commit only briefly mentions "command pollution" without any explanation.
- relates to
-
MODULES-3839 PowerShell Manager host will propagate user code syntax errors in a confusing way
-
- Resolved
-