CircleCI-Public / orb-tools-orb

Various tools for authoring and publishing CircleCI orbs
https://circleci.com/orbs/registry/orb/circleci/orb-tools
MIT License
50 stars 74 forks source link

RC010 erroneously fails if no parameters are specified for a command #209

Closed chasinglogic closed 1 year ago

chasinglogic commented 1 year ago

Orb version: 12.0

What happened:

When authoring an orb and writing a command with no parameters (i.e. completely omitted from the file) then the RC010 check fails with the following error message:

(in test file review.bats, line 205)
  `ORB_COMPONENT_PARAMETERS_COUNT=$(yq '.parameters | keys | .[]' "$i")' failed
Error: Cannot get keys of !!null, keys only works for maps and arrays

This is because it is not checking if there are parameters to get and yq fails if you reference a non existent key.

Expected behavior:

The check should be skipped for parameters

Additional Information:

If you specify parameters: {} then RC010 works fine but then you fail during the orb-tools/pack job with the following:

Error: ERROR IN CONFIG FILE:
[#/commands/tag_new_version] 0 subschemas matched instead of one
1. [#/commands/tag_new_version] expected type: String, found: Mapping
|   Command may be a string reference to another command
2. [#/commands/tag_new_version/parameters] minimum size: [1], found: [0]
|   Parameters given to a step.
|   SCHEMA:
|     minProperties: 1
|   INPUT:
|     {}

Exited with code exit status 255
KyleTryon commented 1 year ago

I'm on it! Thank you @chasinglogic

chasinglogic commented 1 year ago

@KyleTryon I'm about to open a PR