Task randomly fails with 'Error code 5' #387
-
Description of the issue Task randomly fails with 'Error code 5' when running a scan on bicep templates. I say randomly, since rerun of same task (identical configuration) can succeed, or fail a few more times before eventually succeeding. Configuration Yaml configuration of the extension.
Expected behaviour Task to succeed in providing scan results Error output Last logs before error: Then error:
Task in use and version:
From DevOps extension details: From task execution log: Additional context Additional logs:
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
@dkaubar Thanks for logging the issue. We might need to enable verbose logging to understand what error code 5 is related to, as it is not a PSRule specific error. It means access denied. However I suspect that the issue may be related to the For bicep expansion to work, For example: - task: ps-rule-assert@1
displayName: "Run PSRule scan"
inputs:
path: "$(System.DefaultWorkingDirectory)"
inputType: "repository"
inputPath: "$(projectDirectory)/devops/infrastructure/bicep/*.bicep"
modules: "PSRule.Rules.Azure"
outputFormat: "NUnit3"
outputPath: "$(Pipeline.Workspace)/PSRule/ps-rule-results.xml" See Creating your pipeline for additional required configuration. If that does not resolve the issue. Can you please enable verbose logging by setting the This should generate a lot of additional output and should give us an idea where the problem is. |
Beta Was this translation helpful? Give feedback.
-
will try that, thanks! |
Beta Was this translation helpful? Give feedback.
-
so far I was not able to reproduce the issue with inputType: repository I would however like to ask a bit about this configuration:
where only inputType is different (inputPath -> repository) and the path itself points to the exact files we want to target (and not the repository)? also, unrelated, but in logs we see warnings for every .bicep file, like: |
Beta Was this translation helpful? Give feedback.
-
@dkaubar That's great. Thanks for the feedback. When For example, a JSON file: [
{
"name": "object1"
},
{
"name": "object2"
}
] Bicep and Azure template formats are a little tricky, they have parameters, variables, functions, loops, conditions, etc within their structure. Reading the objects is not a good indication of what resources would be deployed to Azure, or what their final state would be. The With Additionally, with In terms of the warning, yes that is expected. You are correct, the files are not being processed by any rule which is the reason for the warning. We could do better to hide this by default, however you can disable the warning by setting the Execution.NotProcessedWarning option to I hope that helps. |
Beta Was this translation helpful? Give feedback.
@dkaubar That's great. Thanks for the feedback.
When
inputType: inputPath
is used a limited number of file formats are loaded from disk a read as objects. Supported formats are listed under the Input.Format.For example, a JSON file:
Bicep and Azure template formats are a little tricky, they have parameters, variables, functions, loops, conditions, etc within their structure. Reading the objects is not a good indication of what resources would be deployed to Azure, or what their final state would be.
The
repository
option discovers the files and passed them through some additional functions to expand the Azure resources from…