Fix FilePattern schema to accept plain strings#1564
Merged
Conversation
Co-authored-by: j178 <[email protected]>
Copilot
AI
changed the title
[WIP] Fix schema validation for FilePattern in pre-commit config
Fix FilePattern schema to accept plain strings
Feb 4, 2026
j178
approved these changes
Feb 4, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1564 +/- ##
==========================================
- Coverage 91.57% 91.56% -0.02%
==========================================
Files 92 92
Lines 17912 17907 -5
==========================================
- Hits 16403 16396 -7
- Misses 1509 1511 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a critical schema validation bug where the JSON schema for FilePattern didn't accept plain strings, causing existing pre-commit configs to fail validation even though they deserialize correctly.
Changes:
- Updated
FilePattern::json_schema()to accept plain strings as regex patterns (replacing the non-existent{ regex: "..." }object format) - Regenerated
prek.schema.jsonto reflect the correct schema
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| crates/prek/src/schema.rs | Fixed FilePattern schema to accept plain strings as the first oneOf variant, matching deserializer behavior |
| prek.schema.json | Regenerated schema file reflecting the corrected FilePattern definition |
📦 Cargo Bloat ComparisonBinary size change: +0.00% (23.2 MiB → 23.2 MiB) Expand for cargo-bloat outputHead Branch ResultsBase Branch Results |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The JSON schema for
FilePatternrequired object notation ({ regex: "..." }or{ glob: "..." }), but the deserializer accepts plain strings as regex patterns. This caused existing pre-commit configs to fail validation:Changes
FilePattern::json_schema()to accept plain strings as the firstoneOfvariant{ regex: "..." }object formatprek.schema.jsonThe schema now matches deserialization behavior, accepting:
exclude: fooexclude: { glob: "*.py" }exclude: { glob: ["*.py", "*.pyc"] }Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
dl.google.com/home/REDACTED/work/prek/prek/target/debug/prek /home/REDACTED/work/prek/prek/target/debug/prek run -v ests/.tmpxZ661R/home/tools/bun/1--no-legend -c 26059e236b3af6dd -c rgo/bin/git -c core.autocrlf=fa/usr/bin/runc -c /usr/lib/git-cor/var/run/docker/runtime-runc/moby -c alse diff cal/share/prek/tjson prek lse REDACTED cal/share/prek/tests/.tmp47umK4/--log(dns block)/home/REDACTED/work/prek/prek/target/debug/prek /home/REDACTED/work/prek/prek/target/debug/prek run [email protected] -c init.defaultBranch=master init -c ash -c core.autocrlf=fa-V=full -c /home/REDACTED/woradd inst�� [email protected] runtime-runc/moby ker/cli-plugins/docker-buildx io.containerd.rugit -c ndor/bin/git ests/.tmpmkmZcy/-c(dns block)https://api.github.com/repos/JuliaData/Parsers.jl/tarball/7d2f8f21da5db6a806faf7b9b292296da42b2810/usr/bin/julia julia --startup-file=no --project=/home/REDACTED/.local/share/prek/tests/.tmpQgvNJR/home/hooks/julia-mo2YGycXuPDVHTHr66kQ -e using Pkg Pkg.instantiate() if !isempty(ARGS) Pkg.add(ARGS) end -- JSON cal/bin/git io.containerd.rucabal -c b6bd62e0e24da6a3--installdir(http block)https://api.github.com/repos/JuliaIO/JSON.jl/tarball/b3ad4a0255688dcb895a52fafbaae3023b588a90/usr/bin/julia julia --startup-file=no --project=/home/REDACTED/.local/share/prek/tests/.tmpQgvNJR/home/hooks/julia-mo2YGycXuPDVHTHr66kQ -e using Pkg Pkg.instantiate() if !isempty(ARGS) Pkg.add(ARGS) end -- JSON cal/bin/git io.containerd.rucabal -c b6bd62e0e24da6a3--installdir(http block)https://api.github.com/repos/JuliaLang/Example.jl/tarball/e1f0e1a832ccd8e97d6d0348dec33ee139a5aeaf/usr/bin/julia julia --startup-file=no --project=/home/REDACTED/.local/share/prek/tests/.tmpi2ZPor/home/hooks/julia-OxpLueuq5IwZtYFFtqW0 -e using Pkg Pkg.instantiate() if !isempty(ARGS) Pkg.add(ARGS) end -- ions }}' 14.1 -- vethd953e24 t 14.1 buil�� --tag prek-2f61e2cf9121d624 ./runghc-9.14.1 org.opencontainejulia 62d173ef org.opencontaine--project=/home/REDACTED/.local/share/prek/tests/.tmpQgvNJR/home/hooks/julia-mo2YGycXuPDVHTHr66kQ ./runghc-9.14.1(http block)https://api.github.com/repos/JuliaLang/PrecompileTools.jl/tarball/07a921781cab75691315adc645096ed5e370cb77/usr/bin/julia julia --startup-file=no --project=/home/REDACTED/.local/share/prek/tests/.tmpQgvNJR/home/hooks/julia-mo2YGycXuPDVHTHr66kQ -e using Pkg Pkg.instantiate() if !isempty(ARGS) Pkg.add(ARGS) end -- JSON cal/bin/git io.containerd.rucabal -c b6bd62e0e24da6a3--installdir(http block)https://api.github.com/repos/JuliaPackaging/Preferences.jl/tarball/522f093a29b31a93e34eaea17ba055d850edea28/usr/bin/julia julia --startup-file=no --project=/home/REDACTED/.local/share/prek/tests/.tmpQgvNJR/home/hooks/julia-mo2YGycXuPDVHTHr66kQ -e using Pkg Pkg.instantiate() if !isempty(ARGS) Pkg.add(ARGS) end -- JSON cal/bin/git io.containerd.rucabal -c b6bd62e0e24da6a3--installdir(http block)https://api.github.com/repos/JuliaServices/StructUtils.jl/tarball/9297459be9e338e546f5c4bedb59b3b5674da7f1/usr/bin/julia julia --startup-file=no --project=/home/REDACTED/.local/share/prek/tests/.tmpQgvNJR/home/hooks/julia-mo2YGycXuPDVHTHr66kQ -e using Pkg Pkg.instantiate() if !isempty(ARGS) Pkg.add(ARGS) end -- JSON cal/bin/git io.containerd.rucabal -c b6bd62e0e24da6a3--installdir(http block)mirrors.aliyun.com/home/REDACTED/work/prek/prek/target/debug/prek /home/REDACTED/work/prek/prek/target/debug/prek run [email protected] commit -m Add large file -c e -c lse -c -config.yaml rev-�� SMonitor=false add ch=master alse -c git git(dns block)/home/REDACTED/work/prek/prek/target/debug/prek /home/REDACTED/work/prek/prek/target/debug/prek run [email protected] -c init.defaultBranch=master init -c rgo/bin/git -c lse -c est -c alse -c e -c lse -c est(dns block)/home/REDACTED/work/prek/prek/target/debug/prek /home/REDACTED/work/prek/prek/target/debug/prek hook-impl --hook-dir /home/REDACTED/.local/share/prek/tests/.tmp3rS68w/temp/.git/hooks --script-version 4 --hook-type=pre-commit -- -c MRTUXB -c git -c alse -c e -c lse -c est(dns block)mirrors.cloud.tencent.com/home/REDACTED/work/prek/prek/target/debug/prek /home/REDACTED/work/prek/prek/target/debug/prek run [email protected] commit -m Add large file -c e -c lse -c -config.yaml rev-�� SMonitor=false add ch=master alse -c git git(dns block)/home/REDACTED/work/prek/prek/target/debug/prek /home/REDACTED/work/prek/prek/target/debug/prek run [email protected] -c init.defaultBranch=master init -c rgo/bin/git -c lse -c est -c alse -c e -c lse -c est(dns block)/home/REDACTED/work/prek/prek/target/debug/prek /home/REDACTED/work/prek/prek/target/debug/prek hook-impl --hook-dir /home/REDACTED/.local/share/prek/tests/.tmp3rS68w/temp/.git/hooks --script-version 4 --hook-type=pre-commit -- -c MRTUXB -c git -c alse -c e -c lse -c est(dns block)pkg.julialang.org/usr/bin/julia julia --startup-file=no --project=/home/REDACTED/.local/share/prek/tests/.tmpQgvNJR/home/hooks/julia-mo2YGycXuPDVHTHr66kQ -e using Pkg Pkg.instantiate() if !isempty(ARGS) Pkg.add(ARGS) end -- JSON cal/bin/git io.containerd.rucabal -c b6bd62e0e24da6a3--installdir(dns block)/usr/bin/julia julia --startup-file=no --project=/home/REDACTED/.local/share/prek/tests/.tmpi2ZPor/home/hooks/julia-OxpLueuq5IwZtYFFtqW0 -e using Pkg Pkg.instantiate() if !isempty(ARGS) Pkg.add(ARGS) end -- ions }}' 14.1 -- vethd953e24 t 14.1 buil�� --tag prek-2f61e2cf9121d624 ./runghc-9.14.1 org.opencontainejulia 62d173ef org.opencontaine--project=/home/REDACTED/.local/share/prek/tests/.tmpQgvNJR/home/hooks/julia-mo2YGycXuPDVHTHr66kQ ./runghc-9.14.1(dns block)pypi.tuna.tsinghua.edu.cn/home/REDACTED/work/prek/prek/target/debug/prek /home/REDACTED/work/prek/prek/target/debug/prek run [email protected] commit -m Add large file -c e -c lse -c -config.yaml rev-�� SMonitor=false add ch=master alse -c git git(dns block)/home/REDACTED/work/prek/prek/target/debug/prek /home/REDACTED/work/prek/prek/target/debug/prek run [email protected] -c init.defaultBranch=master init -c rgo/bin/git -c lse -c est -c alse -c e -c lse -c est(dns block)/home/REDACTED/work/prek/prek/target/debug/prek /home/REDACTED/work/prek/prek/target/debug/prek hook-impl --hook-dir /home/REDACTED/.local/share/prek/tests/.tmp3rS68w/temp/.git/hooks --script-version 4 --hook-type=pre-commit -- -c MRTUXB -c git -c alse -c e -c lse -c est(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
FilePatterndoesn't include strings so validation of pre-commit compatible config files fails #1563💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.