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

Abierto
#1,665 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 6 días

Nadie ha tomado este issue todavía.

  • #1667 de @granbellllc-png — cerrado sin fusionar

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
45/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
go
Área
search

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Go
Estrellas
15.7k
Forks
1.4k
Merge medio
9 d 6 h
PR fusionados (30 d)
8

Preparar el entorno

  • Incluye un Dockerfile o un archivo de Docker Compose
  • Tiene una plantilla de pull request
  • Sin guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de apache/answer

Todos los issues de apache/answer

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.