Skip to content

Regression in renovate regex comprehension #518

Closed
@Callek

Description

Similar to #516 and with a similar workaround I can't update to the newest (0.31.0) check-jsonschema via pre-commit due to this regression in renovate.

Example renovate.json

{
  "$schema": "https://docs.renovatebot.com/renovate-schema.json",
  "customManagers": [
    {
      "description": "Update rust toolchain declarations of dtolnay/rust-toolchain",
      "customType": "regex",
      "fileMatch": [
        "\\.github/(?:workflows|actions)/.+\\.ya?ml$",
        "(^|/)action\\.ya?ml$"
      ],
      "matchStrings": [
          "# renovate: rust-toolchain\\s*toolchain\\:\\s*(?<currentValue>\\d+\\.\\d+(\\.\\d+)?)"
      ],
      "depNameTemplate": "rust",
      "packageNameTemplate": "rust-lang/rust",
      "datasourceTemplate": "github-tags"
    }
  ]
}

Verification that its fixed with nonunicode

$ check-jsonschema --version
check-jsonschema, version 0.31.0
$ check-jsonschema --builtin-schema renovate renovate.json 
Schema validation errors were encountered.
  renovate.json::$.customManagers[0].matchStrings[0]: '# renovate: rust-toolchain\\s*toolchain\\:\\s*(?<currentValue>\\d+\\.\\d+(\\.\\d+)?)' is not a 'regex'
$ check-jsonschema --builtin-schema renovate --regex-variant nonunicode renovate.json 
ok -- validation done

Environment Details

  • MacOS Sequoia
  • Bash + Python3.12

(Though I don't think the environment matters in this case)

Activity

sirosen

sirosen commented on Jan 25, 2025

@sirosen
Member

Thanks for filling this!

I'm starting to regret not doing more research before choosing Unicode mode as the default. With these issues cropping up, I'm doubting that decision a bit.

To keep churn in the project to a minimum, I'll most likely mark the renovate hook as nonunicode in the next release (possibly today, if I can get some time).

I want to look at why that pattern fails though -- it's not obvious to me why the Unicode mode regex engine fails it. Maybe something about the capture group?

added
bugSomething isn't working
pre-commit-hooksRegarding the hook config or generation
on Jan 25, 2025
sirosen

sirosen commented on Jan 25, 2025

@sirosen
Member

I just checked using my browser and the issue with that regex is that there's an improper escape, \:.
Nonunicode mode will, indeed, accept that expression because it is less strict.

This might be evidence of the 0.31.0 update catching a (trivial) mistake in your usage? But if the regex works in renovate then they're probably not evaluating regexes in Unicode mode. So I think that (since renovate is implemented in JS), I'll proceed with the change in hook config, to try to match their implementation.

Callek

Callek commented on Jan 25, 2025

@Callek
Author

the issue with that regex is that there's an improper escape, :

Good catch, but i agree with your planned outcome anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpre-commit-hooksRegarding the hook config or generationregular-expressionsRelated to the regex engines and modes

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Regression in renovate regex comprehension Β· Issue #518 Β· python-jsonschema/check-jsonschema