Closed jwarner112 closed 4 years ago
Hey @jwarner112, thanks for the report! I'm currently deploying a fix for this, so we'll now be correctly handling weird-looking plugin stanzas, and in the event it's not something we can handle, return the 422 error we intend to.
Thanks very much! I appreciate the prompt response and fix. :+1:
Context
When testing that a pipeline was properly configured, I encountered a
500
error during the pipeline upload:Investigation
By process of elimination, I've determined the error occurs when the
plugins
field of a step receives a list of lists, as opposed to the list of maps that it's anticipating.Consider the following document:
This is valid YAML that I've verified with Python 3.4.3 and PyYAML 5.1.2 by the following bash invocation:
The YAML above does not produce the error. However, I hate YAML and in the pursuit of cleaning it up a bit, stumbled into the bug. I was refactoring the above to:
This particular pipeline will have an arbitrary number of steps, each with one of several plugins. There would be a lot of duplication, but inconsistently so, that would not be easily addressed without the refactor. Most importantly, I won't be maintaining this going forward so I'm trying to make it clean and easy to understand for the maintainers.
Bug
Unfortunately, one weakness of the approach above is that it's easy to accidentally provide a list via these aliases instead of a map, as the plugin expects:
intended YAML
typo'd YAML
Both of these are valid YAML, but the latter is not what
plugins
expects to see and causes the500
error. I verified this by removing the aliases and hardcoding the entry as a list of lists, and reproduced the error.Proposed Resolution
I suppose whether or not this is/isn't expected behavior can be debated, but I'm hoping that at the minimum, this case can be detected and the error code changed from
500
to422
, as suggested by this StackOverflow answer.Considering the other error codes:
500
codes imply that the impetus for resolution rests with BuildKite300
,200
, and100
blocks are wholly inappropriate returnsConsidering
422 (Unprocessable Entity)
(source):