Repository navigation
Validate pr template regexes up front, and stop recursive matches panicking - #855
Merged
Merged
Conversation
…icking An automation's regexes were compiled lazily while applying it: regex replacements first, file updates per file during the walk. An invalid one failed halfway, after earlier files had changed, with Go's bare "error parsing regexp" naming neither the field nor the replacement. With the recursive match strategy, an invalid regex after the first panicked out of ReplaceAllFunc. * Apply compiles every regex the updates use (regexReplacements, files and regexes, rendered the way applying them renders them) after Lua and before anything is written, and reports e.g. updates.regexReplacements[1].regex "(image: (.*)" isn't a valid regular expression: missing closing ) * recursiveReplace returns a nested error instead of panicking Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
plural-copilot
Bot
requested review from
floreks,
maciaszczykm,
michaeljguarino and
zreigz
as code owners
December 2, 2026 20:28
Contributor
Confidence Score: 4/5
[Medium impact] The changes affect PR-template application in working directories. The PR appears safe to merge, with a non-blocking request to test the recursive error fix directly. Findings
SummaryThis PR checks update regexes after Lua runs and before file changes begin.
The only finding is a missing direct test for the recursive error fix. No blocking behavior or security issue was found. Reviews (1) · Last reviewed commit: "Validate pr template regexes up front, a..." · Reviewed by Greptile |
Apply rejects invalid regexes up front now, so TestApplyRejectsInvalidRegexes never reaches recursiveReplace. Call it directly with a matching first pattern and an invalid second one: it returns the error without panicking and leaves the input unchanged (the test fails against the old panic). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
michaeljguarino
approved these changes
Dec 2, 2026
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.
Summary
A pull request automation whose regex was
(image: (.*)failed every pull request it created, and the user only saw an opaque error in console. Two problems inpkg/pr:error parsing regexp: ..., naming neither the field nor which replacement it came from.ReplaceAllFuncinstead of returning an error.Changes
Applycompiles every regex the updates use (regexReplacements[].regex,files,regexes), rendered the way applying them renders them, after Lua (which can change the spec) and before anything is written. Errors name the field and the pattern, e.g.updates.regexReplacements[1].regex "(image: (.*)" isn't a valid regular expression: missing closing )recursiveReplacereturns a nested error instead of panicking.Test Plan
TestApplyRejectsInvalidRegexescovers each field, a templated regex checked as rendered, PCRE-only syntax RE2 rejects, and an invalid regex after the first in a recursive match. Every case asserts the working tree is untouched.go test ./pkg/pr/passes; golangci-lint reports 0 issues.Console ships the CLI as a release binary (
CLI_VERSIONin itsDockerfile), so it picks this up once a release includes it and the pin is bumped. The console side is in pluralsh/console#4775.🤖 Generated with Claude Code