Skip to content

fix(search): hyphenated authors and uppercase operators - #115

Merged
19-84 merged 1 commit into
mainfrom
fix/author-operator-hyphen
Sep 30, 2026
Merged

19-84 merged 1 commit into
mainfrom
fix/author-operator-hyphen

Conversation

@19-84

@19-84 19-84 commented Sep 30, 2026

Copy link
Copy Markdown
Owner

Fixes two bugs in the search operator parser (utils/search_operators.py).

1. Uppercase operators stay in the search text (all operators)

SafeRegex.sub called re.sub(pattern, repl, text, flags). The 4th positional parameter of re.sub is count, so re.IGNORECASE became count=2 and matching stayed case-sensitive. Operators are extracted case-insensitively (search passes flags correctly) but were never removed. The literal AUTHOR:bob stayed in the full-text query.

Live check against a local archive via /api/v1/search:

Query main this branch
comment author:test_user_0 10 10
comment AUTHOR:test_user_0 0 10

Fix: re.sub(..., flags=flags) in utils/regex_utils.py.

2. Hyphenated usernames get cut off

author:/user: matched \w+, but Reddit usernames can contain -:

author:some-user z  →  author="some", query="-user z"   (before)
author:some-user z  →  author="some-user", query="z"    (after)

The leftover -user also 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.

  • Full suite: 978 passed. ruff clean. pyright 0 errors.

🤖 Generated with Claude Code

https://claude.ai/code/session_01MjiSEYcZ2q8F7bke96VGHT

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
@19-84
19-84 merged commit d2bc8d9 into main Sep 30, 2026
11 checks passed
@19-84
19-84 deleted the fix/author-operator-hyphen branch September 30, 2026 01:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant