Query with an include path through an inherited object member fails with an internal server error
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 74/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- javascript, mongodb, nodejs, postgres
- Lĩnh vực
- backend
Hướng nghiên cứu
Bắt đầu từ cây thực thi được xây dựng trong handleInclude ở src/RestQuery.js (khoảng dòng 1090-1102), nơi phép tra cứu trên đối tượng thường current[node] khớp với các thành viên kế thừa từ Object.prototype. Kiểm tra cách keys và excludeKeys đưa dữ liệu vào đường dẫn này thông qua phép suy ra include cấp n-1 gần dòng 169. Tái hiện bằng include=valueOf.x và so sánh với include=nope.x. Hoàn thành khi các yêu cầu với tên kế thừa trả về 200 hoặc lỗi 4xx và không còn gây ra lỗi 500.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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)
- Ngôn ngữ chính
- JavaScript
- Star
- 21.4k
- Fork
- 4.8k
- Merge trung bình
- 6 giờ 46 phút
- Pull request đã merge (30 ngày)
- 79
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của parse-community/parse-server
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
parse-community/parse-server#10794 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Add MongoDB 9 supportCó thể đã có người làm @ga262 đã nhận 14 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
parse-community/parse-server#10750 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
parse-community/parse-server#10720 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
parse-community/parse-server#10710 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Node.js version in `.nvmrc` does not satisfy `engines.node`Có thể đã có người làm @kokokoXUY đã nhận 23 ngày trước. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
parse-community/parse-server#10699 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của parse-community/parse-server
Issue tương tự
-
Admin search throws for permissions added through Admin.generalIndexItems('permissions', ...)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
maintenance
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 75/100
alphagov/accessible-autocomplete#826 ·
Maintainer thường phản hồi trong vòng 4 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
olahol/react-tagsinput#229 ·
-
[BUG] npm pkg delete removes the first array item for a nonexistent propertyCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
jonathanong/no-mistakes#2260 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày