Uploaded image for project: 'Modules'
  1. Modules
  2. MODULES-3839

PowerShell Manager host will propagate user code syntax errors in a confusing way

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: PowerShell 2.0.3
    • Component/s: powershell
    • Labels:
      None
    • Template:
    • Acceptance Criteria:
      • Should refer to a valid line and char number in the usercode in the error message instead of in the powershell manager code
      • Not not refer to throw $_.Exception.InnerException in the error message
    • Story Points:
      1
    • Sprint:
      Windows 2016-09-07, Modules 2016-09-21

      Description

      As part of MODULES-3443, the error code handling was improved to make it easier for users to determine where errors originate from. This code covered exceptions but syntax errors still result in a somewhat ambiguous source.

      e.g.

      Manifest - Fail to close the if statement with a closing '}'

      exec { 'cwd test':
          command   => "\$ErrorActionPreference = 'Stop';\n\n if (1 -ne 2) {\n\n Write-Host 'failwhale'\n",
          logoutput => true,
          provider  =>  powershell,
      }
      

      Puppet apply error - Debug

      lbnQgYmxvY2suCg1BdCBsaW5lOjg2IGNoYXI6OQ0KKyAgICAgICAgIHRocm93ICRfLkV4Y2VwdGlvbi5Jbm5lckV4Y2VwdGlvbg0KKyAgICAgICAgIH5+fn5+fn5+fn5+fn5+fn5+fn5+fn5+fn5+fn5+fn5+fg==</Property><Property Name="stdout"></Property></ReturnResult>
       
      Debug: 2016-09-06 12:56:00 -0700 PIPE>
       
      Debug: 2016-09-06 12:56:00 -0700 PIPE>
       
      Debug: Wait object signaled
      Debug: Waited 200 total milliseconds.
      Debug: STDERR: Missing closing '}' in statement block.
      At line:86 char:9
      +         throw $_.Exception.InnerException
      +         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      Error: $ErrorActionPreference = 'Stop';
       
       if (1 -ne 2) {
       
       Write-Host 'failwhale'
       returned 1 instead of one of [0]
      Error: /Stage[main]/Main/Exec[cwd test]/returns: change from notrun to 0 failed: $ErrorActionPreference = 'Stop';
       
       if (1 -ne 2) {
       
       Write-Host 'failwhale'
       returned 1 instead of one of [0]
      Debug: Class[Main]: Resource is being skipped, unscheduling all events
      Debug: Stage[main]: Resource is being skipped, unscheduling all events
      Debug: Finishing transaction 51536020
      Debug: Storing state
      Debug: Stored state in 0.02 seconds
      

      Note that it refers to throw $_.Exception.InnerException and Line 86

      This ticket would be to investigate how to better present syntax errors to the user and tests for the behaviour

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              erick Erick Banks
              Reporter:
              glenn.sarti Glenn Sarti
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Zendesk Support