Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azp: missing parameter names are not reported #237

Open
bryanbcook opened this issue Oct 14, 2023 · 5 comments
Open

azp: missing parameter names are not reported #237

bryanbcook opened this issue Oct 14, 2023 · 5 comments
Labels
bug Something isn't working

Comments

@bryanbcook
Copy link

bryanbcook commented Oct 14, 2023

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
Copy link
Author

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

@ChristopherHX
Copy link
Owner

ChristopherHX commented Oct 20, 2023

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
Copy link
Author

Can you provide a sample that caused the error?

@ChristopherHX
Copy link
Owner

ChristopherHX commented Oct 20, 2023

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
Copy link
Author

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

bryanbcook added a commit to bryanbcook/runner.server that referenced this issue Oct 20, 2023
ChristopherHX pushed a commit that referenced this issue Oct 20, 2023
* Improve error handling for un-named parameters #237

* added missing error handler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants