Skip to content

Azure Pipelines boolean regex error #42

@jamescw19

Description

@jamescw19

The Azure Pipelines schema lists a definition for boolean objects, which is essentially a regex for a series of "boolean-like" inputs.
In my pipeline, I'm using a YAML boolean value:

steps: 
  - script: echo "Hello world"
    continueOnError: true

This raises the following error:

$ check-jsonschema --builtin-schema vendor.azure-pipelines --data-transform azure-pipelines azure-pipelines.yml
  azure-pipelines.yml::$: {'steps': [{'script': 'echo "Hello world"', 'continueOnError': True}]} is not valid under any of the given schemas
  Underlying errors caused this.
  Best Match:
    $: {'steps': [{'script': 'echo "Hello world"\n', 'continueOnError': True}]} is not of type 'string'

If I change the continueOnError value to explicitly be a string, this passes:

steps: 
  - script: echo "Hello world"
    continueOnError: "true"

It seems like Azure and the VSCode pipeline validation tool are casting true as "true" which passes the regex, but check-jsonschema converts this to the Python bool True which fails to match the regex. Given the Azure documentation contains a number of examples where the boolean true is used, this causes valid pipelines to fail with check-jsonschema.

I'm not sure about the other vendors, but the "boolean-as-a-string" definition is potentially an Azure-only issue.
But I'm not sure why the error would occur at all, because a json.dumps on a {"continueOnError": True} dict results in the lowercase {"continueOnError": true} JSON object, so perhaps this is an issue with the jsonschema package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    azure-schema-liesThe Azure Pipelines Schema is at it againupstream-schema-issueAn issue with a schema or schema provider

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions