Query with an include path through an inherited object member fails with an internal server error
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 74/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- javascript, mongodb, nodejs, postgres
- Ambito
- backend
Direzione di ricerca
Inizia dall'albero di esecuzione costruito in handleInclude in src/RestQuery.js (intorno alle righe 1090-1102), dove la ricerca su oggetto semplice current[node] corrisponde ai membri ereditati di Object.prototype. Verifica come keys e excludeKeys alimentano quel percorso tramite la derivazione dell'include a livello n-1 vicino alla riga 169. Riproduci con include=valueOf.x e confrontalo con include=nope.x. È fatto quando le richieste con nomi ereditati restituiscono 200 o un errore 4xx e non generano più un 500.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Issue Description
A query whose include path contains a component that happens to name an inherited Object.prototype member — for example valueOf, hasOwnProperty, toString, isPrototypeOf, __defineGetter__ — fails with HTTP 500 and error code 1 (Internal server error). A path component naming any other non-existent field is handled normally and returns 200.
The cause is the execution tree that handleInclude builds from the include paths (src/RestQuery.js:1090-1102):
const executionTree = {}
this.include.forEach(path => {
let current = executionTree;
path.forEach((node) => {
if (!current[node]) {
current[node] = {
path,
children: {}
};
}
current = current[node].children
});
});
current is a plain object, so for a component such as valueOf the lookup current[node] resolves to the inherited function rather than undefined. Being truthy, it skips the assignment, and current then becomes current[node].children, which is undefined. The next component dereferences undefined, which throws a TypeError and surfaces as HTTP 500.
An own-property check (Object.hasOwn(current, node)), or building the tree with new Map() or Object.create(null), would treat these names like any other field name.
The same failure is reachable through keys and excludeKeys, because those derive n-1-level includes (src/RestQuery.js:169), e.g. keys=valueOf.x.y.
Note that __proto__ and constructor are now rejected with error 105 by the requestKeywordDenylist option (#10793), but the other inherited member names are not part of that denylist.
Steps to reproduce
Send a find request whose include path starts with, or passes through, an inherited Object.prototype member name:
GET /1/classes/Item?include=valueOf.x
GET /1/classes/Item?include=hasOwnProperty.x
GET /1/classes/Item?include=meta.valueOf.x
GET /1/classes/Item?keys=valueOf.x.y
GET /1/classes/Item?excludeKeys=valueOf.x.y
For comparison, a non-existent plain field name in the same position succeeds:
GET /1/classes/Item?include=nope.x
Actual Outcome
include=valueOf.x -> 500 code=1 Internal server error.
include=hasOwnProperty.x -> 500 code=1 Internal server error.
include=toString.x -> 500 code=1 Internal server error.
include=isPrototypeOf.x -> 500 code=1 Internal server error.
include=__defineGetter__.x -> 500 code=1 Internal server error.
include=meta.valueOf.x -> 500 code=1 Internal server error.
keys=valueOf.x.y -> 500 code=1 Internal server error.
excludeKeys=valueOf.x.y -> 500 code=1 Internal server error.
include=nope.x -> 200
Expected Outcome
The request behaves as it does for any other non-existent field name, so include=valueOf.x returns 200 like include=nope.x, or the field name is rejected with a 4xx error.
Environment
Server
- Parse Server version:
9.10.5-alpha.11 - Operating system:
macOS (Darwin 24.6.0) - Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc):
local
Database
- System (MongoDB or Postgres):
MongoDB(also reproduced withPostgres) - Database version:
8.0.4(Postgres 16 / PostGIS 3.5) - Local or remote host (MongoDB Atlas, mLab, AWS, Azure, Google Cloud, etc):
local
Client
- SDK (iOS, Android, JavaScript, PHP, Unity, etc):
REST - SDK version:
n/a
Logs
TypeError: Cannot read properties of undefined (reading 'x')
at src/RestQuery.js (handleInclude, execution tree build)
- Lingua principale
- JavaScript
- Stelle
- 21.4k
- Fork
- 4.8k
- Merge medio
- 6h 46m
- PR unite (30g)
- 79
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di parse-community/parse-server
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
parse-community/parse-server#10794 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Add MongoDB 9 supportForse già presa @ga262 l’ha presa 14 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
parse-community/parse-server#10750 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
parse-community/parse-server#10720 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
parse-community/parse-server#10710 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Node.js version in `.nvmrc` does not satisfy `engines.node`Forse già presa @kokokoXUY l’ha presa 23 giorni fa. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
parse-community/parse-server#10699 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di parse-community/parse-server
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
taskcluster/taskcluster#9284 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Xvesa 24bbp incorrect info?Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Spomky-Labs/pwa-bundle#476 ·
-
[feart] 支持 MiMo 类型模型的关闭思考识别Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
speced/respec#5504 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno