Repository navigation
fix(search): hyphenated authors and uppercase operators - #115
Merged
Merged
Conversation
Two parser bugs in search operators: - SafeRegex.sub passed flags positionally, so re.sub took them as count. re.IGNORECASE never applied to operator removal: AUTHOR:bob, Sub:x, SCORE:10 etc. were applied as filters but left in the FTS text, so those searches returned nothing. - author:/user: matched \w+, cutting Reddit usernames at a hyphen. author:some-user filtered on 'some' and turned '-user' into an exclusion term. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MjiSEYcZ2q8F7bke96VGHT
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.
Fixes two bugs in the search operator parser (
utils/search_operators.py).1. Uppercase operators stay in the search text (all operators)
SafeRegex.subcalledre.sub(pattern, repl, text, flags). The 4th positional parameter ofre.subiscount, sore.IGNORECASEbecamecount=2and matching stayed case-sensitive. Operators are extracted case-insensitively (searchpasses flags correctly) but were never removed. The literalAUTHOR:bobstayed in the full-text query.Live check against a local archive via
/api/v1/search:comment author:test_user_0comment AUTHOR:test_user_0Fix:
re.sub(..., flags=flags)inutils/regex_utils.py.2. Hyphenated usernames get cut off
author:/user:matched\w+, but Reddit usernames can contain-:The leftover
-useralso became an exclusion term. Pattern is now[\w-]+.sub:is unchanged; subreddit names cannot contain hyphens.Tests
13 new tests, all failing on main. The existing case-insensitive tests checked only the extracted value, never
query_text. That is how bug 1 went unnoticed.🤖 Generated with Claude Code
https://claude.ai/code/session_01MjiSEYcZ2q8F7bke96VGHT