ChristopherHX / runner.server

An unofficial Local GitHub Actions and Azure Pipelines Emulator
MIT License
169 stars 15 forks source link

azp: missing parameter names are not reported #237

Open bryanbcook opened 11 months ago

bryanbcook commented 11 months ago

Consider the following

# pipeline.yml
steps:
- template: steps.yml
# steps.yml
parameters:
- name: required
  type: string
  # no default value

steps:
- script: exit 0

Should report an error message A value for the 'required' parameter must be provided

No error message is reported

bryanbcook commented 11 months ago

The fix for this was merged, can we cut a new release?

ChristopherHX commented 11 months ago

I still want to resolve this error, could be related with your change. Visible in vscode extension 0.0.4 (the current main branch)

System.ArgumentNullException: Value cannot be null. (Parameter 'key')
   at System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Int32, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].FindValue(String key)
   at System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Int32, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].TryGetValue(String key, Int32& value)
   at GitHub.DistributedTask.Pipelines.ContextData.DictionaryContextData.set_Item(String key, PipelineContextData value)
   at AzureDevops.ReadTemplate(Context context, String filenameAndRef, Dictionary`2 cparameters, String schemaName)
   at MyClass.ExpandCurrentPipeline(JSObject handle, String currentFileName)

Edit User error, the code needs to validate that the key/name of a sequence parameter is defined

Most of the parser works good with working files, but some error checks are missing

bryanbcook commented 11 months ago

Can you provide a sample that caused the error?

ChristopherHX commented 11 months ago

It is clearly a yaml syntax error and not any regression, so I created a new release 3.11.9 (vscode ext 0.0.4)

parameters:
- parameters: val # <-- syntax error, causes a null exception and doesn't tell what is wrong, you could also just remove the `name` key
  type: object
  default:
  - a
  - b
steps:
- script: echo ${{ converttojson(parameters.val) }}

May be worth to check the error in a unit test, to not be a System.ArgumentNullException or other Null exception

bryanbcook commented 11 months ago

That's an easy test to write. I'll open a PR