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

check-azure-pipelines: doesn't handle default value for boolean parameter properly #403

Closed
karunpoudel-chr opened this issue Feb 29, 2024 · 2 comments
Labels
azure-schema-lies The Azure Pipelines Schema is at it again

Comments

@karunpoudel-chr
Copy link

karunpoudel-chr commented Feb 29, 2024

Following azure-pipelines.yml although valid gives pre-commit error:

parameters:
  - name: myBoolean
    displayName: myboolean
    type: boolean
    default: true

steps:
  - bash: echo "{{ parameters.myBoolean}}"

gives error:
$.parameters[0].default: True is not of type 'string'

Following works (in both pre-commit and azure pipeline) but doesn't look correct to have 'true' for boolean

parameters:
  - name: myBoolean
    displayName: myboolean
    type: boolean
    default: 'true'

steps:
  - bash: echo "{{ parameters.myBoolean}}"

Setup:

  - repo: https://github.com/python-jsonschema/check-jsonschema
    rev: 0.28.0
    hooks:
      - id: check-azure-pipelines
@karunpoudel-chr karunpoudel-chr changed the title check-azure-pipelines: doesn't support default value for boolean parameter? check-azure-pipelines: doesn't handle default value for boolean parameter properly Feb 29, 2024
@sirosen sirosen added the azure-schema-lies The Azure Pipelines Schema is at it again label Mar 1, 2024
@sirosen
Copy link
Member

sirosen commented Mar 1, 2024

The Azure Pipelines schema is provided by Microsoft and has numerous issues and inaccuracies.

I believe that their schema allows for "true" and "false" (the strings) in a number of cases in which "true", "false", true, false should all be allowed. I recommend trying "true" to see if Azure Pipelines and the schema are both happy with that.


I've tried to file upstream issues and even offered to help fix up their schema, and they either haven't understood me or haven't been interested in improving it. Their LSP tools simply patch over these cases by muddling the data before it goes through validation -- I can't remember the exact details, but it's nontrivial to replicate with the check-jsonschema technology stack.1

I don't think that there's an obvious improvement here, unfortunately. It's a pretty disappointing but the underlying schema is where the problem lies.

It's possible that there's some kind of hack which can be applied (like the MSFT LSP tools do), but I haven't figured that out.

Footnotes

  1. Also, on a "pride of craftsmanship" note, I take serious issue with treating "true" and true as equivalent -- they're different values and it's a bad idea to pretend otherwise. It's impossible to scope that change down to the correct scope (what does "correct" even mean in this case?), and it's just as likely to cause harm somewhere else as it is to help here.

@sirosen
Copy link
Member

sirosen commented Mar 31, 2024

As of recent contributions (#407 ! 🙌 ), we have docs for this issue up in the FAQ:
https://check-jsonschema.readthedocs.io/en/stable/faq.html#quoted-boolean-issues

With the last release, that rolled out to the stable docs, so for now I'm going to close this.
I'll note that I still think that there's an issue here, but I think someone would need to come up with an implementation plan before we could really consider trying to make a change. (Simply converting all bools to strings is probably not safe -- the MSFT schema is sufficiently badly behaved that I wouldn't be comfortable shipping that.)

@sirosen sirosen closed this as not planned Won't fix, can't repro, duplicate, stale Mar 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
azure-schema-lies The Azure Pipelines Schema is at it again
Projects
None yet
Development

No branches or pull requests

2 participants