Skip to content

WhatIf report fails with Cannot bind argument to parameter 'FilePath' because it is null #853

Closed
@bjompen

Description

@bjompen

Describe the bug

Verify and create feedback / WhatIf report fails with Cannot bind argument to parameter 'FilePath' because it is null
See image 1 for error, Error 2 for context.

In certain scenarios it appears that WhatIf fails as above. Setting message.info.maximum = 9 and enabling system.debug in Azure DevOps to get all messages let us track the error down to the following scenario:

We are running a serial deploy (Image 3) so in Invoke-AzOpsPush we are either in line 497, line 508 or line 513

Inside New-AzOpsDeployment in out scenario we are running a bicep/json file the scope set is resource group and we end up inside this if statement

Here we run Set-AzOpsContext which is a wrapper around Set-AzContext

The issue now is that Set-AzContext outputs the result of the context switch, and back in the calling script, Invoke-AzOpsPush, the output from Set-AzContext is caught in the $DeploymentResult variable.

In line 518 we output $DeploymentResult to log as can be seen in image 2, and it now contains two objects:

  • Output from Set-AzContext (unwanted)
  • Output from New-AzOpsDeployment (wanted)

The foreach loop following the output fails because the first object is a context object thatm logically enough, doesn't have a $_.filePath property.

Steps to reproduce

Run a verify pipeline with a bicep file? I honestly don`t know if it hits every time, or only when you have to change context.

Extra stuff

I can of course share complete logs, but since they contain sensitive data we can take that in private if needed.

Proposed solution would be to simply change lines 103 and 112 in New-AzOpsDeployment to $null = Set-AzOpsContext -ScopeObject $scopeObject instead and simply ignore any output from it. Let me know if this is good and I'll fix it right away.

Screenshots

Image 1:
image

Image 2:
image

Image 3:
image

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions