Repository navigation
Conversation
SearchDTO.Check only preserved [tag] tokens made of \w characters and then replaced "-", ".", "+" and friends with spaces. A search for [react-native] reached the parser as [react native], no tag has that slug, so the tag filter was silently dropped and results came from every tag. New tags with spaces are saved with "-", so this hits any multi-word tag. Accept any non-space, non-bracket characters inside the brackets. Generated-by: Claude Opus 5.5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for identifying and covering the hyphen/dot/plus slug case. There is one parsing conflict that should be addressed before merging. The new pattern accepts any non-whitespace, non-bracket character inside However,
The same issue applies to Could we first extract and remove complete |
Fixes: n/a (no existing issue; details below)
Proposed Changes
[tag]search filter ("Advanced Search Tips":[tag] search with a tag) is silently ignored when the tag slug contains-,.,+or any other non-\wcharacter. Searching[react-native] navigationreturns matches from every tag instead of onlyreact-native. When a question is created, spaces in a new tag name are saved as-(question_service.go), so every multi-word tag is affected, along with slugs likenode.jsandc++.SearchDTO.Check→ReplaceSearchContentprotects[tag]tokens from the special-character cleanup, but only matches\[\w+\]. A token like[react-native]doesn't match, so the cleanup regex turns it into[react native].SearchParser.parseTagsthen looks up the slugreact native, finds no tag, skips it, and still strips the bracket token. The query then runs with no tag condition at all.ReplaceSearchContentnow accepts any non-space, non-bracket characters:\[[^\[\]\s]+\].parseTagsalready matches\[(.*?)\], so no other change is needed.internal/schema/search_schema_test.goadds[react-native] [node.js] [c++] navigation-bar. Ondev@6c00c788this becomes[react native] [node js] [c ] navigation bar; with the fix the tags stay intact.internal/repo/repo_test/search_tag_filter_test.go(new, ASF header) is an end-to-end test on the SQLite repo test DB. It creates tagssearch-hyphen-tagandsearch.dot.tagand two matching questions, only one of them tagged. It then runs the same path asGET /answer/api/v1/search:SearchDTO.Check→SearchParser.ParseStructure(realTagCommonService) →searchRepo.SearchContents. Ondevit fails withtag filter dropped, query became "[search hyphen tag] tagfilter". With the fix, only the tagged question is returned.go test ./internal/schema/ ./internal/repo/... ./internal/service/...passes, andgo vet,gofmtandgolangci-lintv2.6.2 report 0 issues.This bug was found and the fix and tests were written with AI assistance (Claude); I reviewed the change and ran the tests above.