Skip to content

Schema bug: FilePattern doesn't include strings so validation of pre-commit compatible config files fails #1563

@lf-

Description

@lf-

Summary

Existing pre-commit config files that use file patterns like exclude don't pass yaml schema validation in prek.

This is the definition of global file exclude patterns: use FilePattern.

    "exclude": {
      "description": "Global file exclude pattern.",
      "anyOf": [
        {
          "$ref": "#/definitions/FilePattern"
        },
        {
          "type": "null"
        }
      ]
    },

FilePattern is:

    "FilePattern": {
      "description": "A file pattern, either a regex or glob pattern(s).",
      "type": "object",
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "regex": {
              "description": "A regular expression pattern.",
              "type": "string"
            }
          },
          "required": [
            "regex"
          ]
        },
        {
          "type": "object",
          "properties": {
            "glob": {
              "oneOf": [
                {
                  "description": "A glob pattern.",
                  "type": "string"
                },
                {
                  "description": "A list of glob patterns.",
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              ]
            }
          },
          "required": [
            "glob"
          ]
        }
      ]
    },

Note that it doesn't include being a plain string at the top level of FilePattern. i.e.:

---
exclude: foo

This means that existing pre-commit config files that use exclusions don't pass validation with the provided JSON schema.

Platform

n/a

Version

d42b733

.pre-commit-config.yaml

---
$schema: https://raw.githubusercontent.com/j178/prek/refs/heads/master/prek.schema.json
# yaml-language-server: $schema=https://raw.githubusercontent.com/j178/prek/refs/heads/master/prek.schema.json
exclude: foo

Log file

N/A you don't have to run prek.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinggood first issueGood for newcomers

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions