Searching user:<username> returns the wrong posts when the username starts with "me"

オープン
#1,665 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 6 日以内に返信

まだ誰も着手していません。

  • #1667 @granbellllc-png による — マージされずにクローズ

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
go
領域
search

調査の方向性

The issue identifies the search parser’s strings.Contains(q, "user:me") check and says the bug occurs before search plugins run; it does not name the parser file or an existing test. Start by locating that check and the search parser tests, then verify that user:me still means the current user while user:melissa returns only melissa’s posts. The author says they have a fix and plan to open a pull request, so check for that work before starting.

索引モデルが issue の本文から書いたものです。

説明

Describe the bug

The search tips say user:username searches by author. For any username that starts with me (melissa, megan, meng, mei, ...) the search is treated as user:me instead. A visitor gets results from every author, a signed-in user gets only their own posts, and the rest of the username (lissa) is searched as a word.

The search parser checks strings.Contains(q, "user:me") before it looks up the username, so user:melissa matches that check. This happens before the search plugin is called, so it affects the built-in search and the search plugins alike.

To Reproduce

  1. Create two users, melissa and bob.
  2. As melissa, ask "Which port does the parking service use". As bob, ask "Where is the store service configuration".
  3. Search user:bob: one result, bob's question.
  4. Search user:melissa: no results.
  5. Search user:melissa service while signed out: two results, melissa's and bob's question.

I ran this against dev at ec5e0e9 (SQLite, installed with the AUTO_INSTALL environment variables), calling GET /answer/api/v1/search?order=newest the way the search box does:

q='user:bob' as anonymous               count 1  authors [bob]
q='user:melissa' as anonymous           count 0  authors []
q='user:melissa' as admin               count 0  authors []
q='user:melissa service' as anonymous   count 2  authors [melissa, bob]
q='user:me' as melissa                  count 1  authors [melissa]

Expected behavior

user:melissa returns melissa's posts, the same way user:bob returns bob's. Only user:me itself should mean the current user.

Screenshots

None, the output above is from the API.

Platform

  • Device: Desktop (API calls with curl)
  • OS: Linux (Docker, golang:1.25)
  • Browser and version: not used
  • Version: dev at ec5e0e9; the same check is on main

I have a fix with a test and will open a pull request for it.

主要言語
Go
スター
15.7k
フォーク
1.4k
平均マージ
9日 6時間
マージ済み PR(30日)
8

環境構築

  • Dockerfile または Docker Compose ファイルあり
  • プルリクエストのテンプレートあり
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/answer のほかの issue

apache/answer の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。