fix: sanitise newlines in integration PR titles to prevent GitHub 422 (PTFE-3249)#270
Open
matthiasL-scality wants to merge 1 commit into
Open
fix: sanitise newlines in integration PR titles to prevent GitHub 422 (PTFE-3249)#270matthiasL-scality wants to merge 1 commit into
matthiasL-scality wants to merge 1 commit into
Conversation
…PTFE-3249) A parent PR whose title contains newline characters (e.g. from a multi-line commit message such as "My feature\n* fix something") caused bert-e to forward those newlines in the integration PR title, which GitHub's API rejects with a 422 Unprocessable Entity. Strip \r and \n via re.sub before composing the INTEGRATION title. The inner .strip() prevents a leading \n from causing a double space inside the formatted string; the outer .strip() handles the edge case where the parent title consists entirely of newlines (which would otherwise leave a trailing space after the closing bracket). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #270 +/- ##
==========================================
+ Coverage 89.54% 89.60% +0.05%
==========================================
Files 79 81 +2
Lines 10522 10589 +67
==========================================
+ Hits 9422 9488 +66
- Misses 1100 1101 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
charlesprost
approved these changes
Jun 5, 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
"My feature\n* fix something") caused bert-e to forward those newlines in the integration PR title string, triggering a 422 Unprocessable Entity from GitHub's API.\r/\nviare.subbefore composing theINTEGRATION [...]title inIntegrationBranch.get_or_create_pull_request.helpers.FakeRepoas a shared test stub, and 7 unit tests covering the sanitisation behaviour.Root cause
Fix
The inner
.strip()prevents a leading\n(e.g."\nfoo"→" foo") from introducing a double space inside the formatted string. The outer.strip()handles the pathological case where the parent title consists entirely of newlines, which would otherwise leave a trailing space after the closing bracket.Test plan
test_newline_in_parent_title_is_stripped— core regression casetest_carriage_return_in_parent_title_is_stripped— CRLF varianttest_asterisk_without_newline_is_preserved—*alone is not strippedtest_clean_title_is_unchanged— happy path, no regressiontest_integration_prefix_is_present— prefix always presenttest_trailing_newline_does_not_produce_trailing_space— trailing\ntest_newlines_only_title_does_not_produce_trailing_space— pathological all-newlines title🤖 Generated with Claude Code