Repository navigation
Make the backport PR title configurable - #75
Draft
aiolibsbot wants to merge 1 commit into
Draft
aiolibsbot wants to merge 1 commit into
aiolibsbot wants to merge 1 commit into
Conversation
Adds a `backport_pr_title_template` option to `.github/patchback.yml`,
defaulting to the exact title format shipped so far, so nothing changes
for repos that do not set it.
Substitution is deliberately not `str.format`: a format string read from
repo config could walk attributes (`{x.__class__.__init__.__globals__}`)
or subscript values. Instead, only `{name}` spellings matching `\w+` are
replaced, and only when the name is on an explicit allowlist — anything
else, including every `str.format` escape, is left in the title verbatim
and never evaluated.
A template that names unknown placeholders or renders into an empty
title raises `ValueError` at render time rather than being rejected at
config-parse time. Rejecting the config would let one typo disable
backporting repo-wide; instead the handler falls back to the default
template and surfaces the error in the check run summary, after the
cherry-pick has already been pushed.
Closes sanitizers#25
This was referenced Sep 16, 2026
This branch has not been deployed
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.
What: adds a
backport_pr_title_templateoption to.github/patchback.yml, with a restricted, non-str.formatsubstitution engine.Why: #25 asks for shorter, readable backport titles (release-drafter output, changelogs). @webknjaz's concern there was that user-defined templates are potentially harmful and that this "needs a few restricted substitutions" — that constraint is what the design below is built around.
How:
patchback/pr_title.py— stdlib-only (re). Only{name}spellings matching\w+are substituted, and only whennameis on an explicit allowlist:pr_number,pr_title,target_branch,base_branch,merge_commit_sha,merge_commit_sha_short. Everything else is left in the title verbatim and never evaluated, so the format-string escapes that makestr.formatdangerous on untrusted input —{x.__class__.__init__.__globals__},{x[0]},{x!r},{x:10000000}— are inert text here, not a capability. Rendered titles are whitespace-collapsed so a YAML block template cannot smuggle newlines into a title.get_patchback_config()would let one typo disable backporting repo-wide. Instead the handler falls back to the default template and appends the error to the check-run summary — the cherry-pick has already been pushed by then, so losing the backport over a title is the worse outcome.Testing: 19 tests in
tests/test_pr_title.py, run withpython -m pytest. They cover the default reproducing the historical title byte-for-byte, both title shapes @ssbarnea proposed in #25, every allowlisted name being renderable, the five format-string injection shapes staying literal, unknown placeholders being reported together and by name, empty/whitespace-only results, and newline collapsing. The module imports no third-party code, so the suite needs nothing but pytest.Skipped: no title length cap (GitHub already bounds
pr_title, and current titles are uncapped too) — add one if long templates show up in practice. No{{escape hatch, since no allowlisted name can be produced accidentally. Config options still aren't documented inREADME.md; #57 is rewriting it, so that belongs there.Closes #25
Quality Report
Changes: 4 files changed, 264 insertions(+), 3 deletions(-)
Code scan: clean
Tests: skipped
Branch hygiene: clean
Generated by Kōan