Duplicate Mongoose index on User.email and User.username
Los mantenedores suelen responder en 4 días
@yashgoyal0110 ya está trabajando en esto.
Desde el 4/11/2026.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 72/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- mongodb, typescript
Línea de trabajo
Start in server/models/user.ts, checking the field definitions around lines 15 and 24 and the schema indexes around lines 333–334. Reproduce the startup warning with a local MongoDB connection and inspect existing indexes and case-duplicate rows before changing the definitions. Done means startup has no duplicate-index warning and each field has one case-insensitive unique index, with existing deployments considered.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
p5.js version
N/A this is a server-side (database model) issue, unrelated to the p5.js library version.
What is your operating system?
Mac OS
Web browser and version
N/A backend issue, happens at server startup before any browser is involved.
Actual Behavior
On server startup, Mongoose logs a duplicate-index warning:
Duplicate schema index on {"email":1} found. This is often due to declaring an index using both "index: true" and "schema.index()". Please remove the duplicate index definition.
The same happens for username.
In server/models/user.ts the fields are indexed twice:
username: { type: String, required: true, unique: true }(line 15) andemail: { type: String, unique: true }(line 24) create a unique index viaunique: true- lines 333–334 declare a second index on the same fields with a collation:
userSchema.index({ username: 1 }, { collation: { locale: 'en', strength: 2 } });
userSchema.index({ email: 1 }, { collation: { locale: 'en', strength: 2 } });
On top of the warning, the two indexes aren't equivalent. The unique: true index is case-sensitive and is the only one enforcing uniqueness; the collation index (meant to make lookups case-insensitive) is not unique. So although the model comments say "Email addresses should be case-insensitive unique" and findByEmailAndUsername queries with a collation, the database only enforces case-sensitive uniqueness case-insensitive uniqueness depends entirely on the app-level check at signup (which has a check-then-insert race).
Expected Behavior
No duplicate-index warning at startup, and a single case-insensitive unique index per field so the database itself enforces the case-insensitive uniqueness the code already assumes.
Suggested fix- move uniqueness onto the collation index:
// schema fields
username: { type: String, required: true }, // drop unique: true
email: { type: String }, // drop unique: true
// bottom of file
userSchema.index({ username: 1 }, { unique: true, collation: { locale: 'en', strength: 2 } });
userSchema.index({ email: 1 }, { unique: true, collation: { locale: 'en', strength: 2 } });
(Existing deployments would need the old case-sensitive indexes dropped so the new ones get built, and any pre-existing case-duplicate rows cleaned up first.)
Steps to reproduce
Steps:
- Set up the project locally with a MongoDB connection (copy .env, point MONGO_URL at a running mongo).
- Start the server: npm start
- Watch the server logs on startup the "Duplicate schema index on {email:1}" warning appears (and the same for username).
- Lenguaje dominante
- JavaScript
- Estrellas
- 1.7k
- Forks
- 1.7k
- Merge medio
- 7 d 1 h
- PR fusionados (30 d)
- 13
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de processing/p5.js-web-editor
-
Unable to rename sound filesQuizá libre de nuevo @prithq la tomó hace 7 días y no hay ningún pull request abierto. AbiertoAwaiting Maintainer Approval Bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
processing/p5.js-web-editor#4392 · 2 comentarios ·
Los mantenedores suelen responder en 4 días
-
Renaming a folder doubles the folder name in file paths (console errors show /lib/lib/helper.js)AbiertoAwaiting Maintainer Approval Bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
processing/p5.js-web-editor#4365 · 1 comentario ·
Los mantenedores suelen responder en 4 días
-
p5 logo is broken on verification emailsPosiblemente ocupada @sourabh65mehta la tomó hace 22 días. AbiertoBug
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
processing/p5.js-web-editor#4364 · 2 comentarios · 1 asignado ·
Los mantenedores suelen responder en 4 días
-
`PATCH /editor/project/visibility` returns 200 with `null` and doesn't update when `projectId` is a slugQuizá libre de nuevo @Prbhtsgh la tomó hace 29 días y no hay ningún pull request abierto. AbiertoAwaiting Maintainer Approval Bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
processing/p5.js-web-editor#4348 · 3 comentarios ·
Los mantenedores suelen responder en 4 días
-
Fix: example.js stores defaultHTML function reference instead of calling it, causing examples to display raw JavaScript source in previewPosiblemente ocupada @syedbarkath980 la tomó hace 7 días. AbiertoBug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
processing/p5.js-web-editor#4344 · 3 comentarios · 1 asignado ·
Los mantenedores suelen responder en 4 días
Todos los issues de processing/p5.js-web-editor
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
Add: ON Football HD feed LogoAbiertoapproved check:passed logos:add
Dificultad 1/5 Menos de una hora Aptitud para principiantes 74/100
Los mantenedores suelen responder en 2 días
-
binding:python bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
BUG: Unhandled TypeError in updateMedicine and updateDischargeLog when data is null/undefinedAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
AOSSIE-Org/BabyNest#310 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
bug needs-triage potential-regression
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
aws/aws-sdk-js-v3#8408 ·
Los mantenedores suelen responder en 1 día