Query with an include path through an inherited object member fails with an internal server error
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 74/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- javascript, mongodb, nodejs, postgres
- 領域
- backend
調査の方向性
src/RestQuery.js の handleInclude で構築される実行ツリーから始めてください(1090-1102行付近)。ここでは単純なオブジェクトに対する検索 current[node] が Object.prototype の継承メンバーに一致します。keys と excludeKeys が、169行付近の n-1 レベルの include 導出を通じてこの経路にどう影響するかを確認してください。include=valueOf.x で再現し、include=nope.x と比較してください。継承された名前を含むリクエストが 200 または 4xx エラーを返し、500 エラーが発生しなくなれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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)
- 主要言語
- JavaScript
- スター
- 21.4k
- フォーク
- 4.8k
- 平均マージ
- 6時間 46分
- マージ済み PR(30日)
- 79
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
parse-community/parse-server のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
parse-community/parse-server#10794 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Add MongoDB 9 support対応中かも @ga262 が 13 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
parse-community/parse-server#10750 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
parse-community/parse-server#10720 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
parse-community/parse-server#10710 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Node.js version in `.nvmrc` does not satisfy `engines.node`対応中かも @kokokoXUY が 22 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
parse-community/parse-server#10699 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
parse-community/parse-server の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 65/100
521xueweihan/HelloGitHub#4025 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
iib0011/omni-tools#479 ·
メンテナーはふだん 1 日以内に返信
-
triage
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
pixelfed/pixelfed-rn#508 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
yetone/magpie#2844 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信