Repository navigation
fix: treat a bare-string extra_keywords as one keyword - #10735
Open
FireChickenMP4 wants to merge 1 commit into
Open
FireChickenMP4 wants to merge 1 commit into
FireChickenMP4 wants to merge 1 commit into
Conversation
`extra_keywords` is declared as a list in the config schema, but the loader keeps whatever value it finds, so a hand-edited string is iterated character by character and every character becomes its own keyword. Normalise a bare string to a single-element list before extending the keyword list, and treat an empty string as no keywords.
This was referenced Oct 24, 2026
Contributor
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="tests/test_content_safety_check.py" line_range="100-117" />
<code_context>
assert stopped is expected_stopped
+
+
+def test_keywords_strategy_treats_string_config_as_one_pattern():
+ """A bare-string extra_keywords value is one keyword, not N char patterns.
+
+ The config schema declares a list, but a hand-edited config can hold a plain
+ string. Iterating it turns every character into its own keyword, so any
</code_context>
<issue_to_address>
**Tests are added against guidance**
When the new test cases are included, two new test functions are added, contrary to the repository instruction, so the change introduces test code the guidance says not to generate.
Remove the added test cases to follow the repository guidance.
</issue_to_address>Sourcery assessment
Approved.
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.
Separate from #10697, which handles invalid regex entries. This one is about the
value's type.
extra_keywordsis declared as a list in the config schema, but the loader fillsin missing keys and keeps the value it finds, so a hand-edited config can hold a
plain string:
self.keywords.extend(extra_keywords)then walks characters, so "blocked"becomes seven one-character keywords. Any message containing one of those letters
is blocked: "hello world" is blocked because of the e and the o. The log line
only reports that a keyword matched, so nothing points back at
extra_keywords.The patch wraps a bare string in a list before the extend, and treats an empty
string as no keywords. Configs that already hold a list behave the same.
A non-iterable value still raises
TypeErrorat the extend, same as today; Ileft that alone. Fixing this in the loader would mean type-checking every option,
so the normalisation stays local.
Verification:
Without the normalisation the string test fails: "the old clock" is blocked by the
single-character keywords.