Resource.get(query) receives a RequestTarget: plain property access is silently undefined
维护者通常 2 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 1/5
- 预计耗时
- 1 小时以内
- 新手友好度
- 90/100
- Issue 类型
- 文档
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- javascript, typescript
调研方向
从 reference/resources/resource-api.md 开始,那里描述了 get(query),然后检查 resources/RequestTarget.ts 中直接声明的 framework 属性。使用现有的 target.get('param1') 示例作为上下文。当参考文档明确指出 RequestTarget 扩展了 URLSearchParams,解释自定义参数使用 query.get('name') 以及访问普通属性时会得到 undefined,并列出直接属性时,就算完成。
由索引模型根据 Issue 内容生成。
描述
Document that a custom Resource.get(query) receives a RequestTarget, so plain property access is silently undefined
The trap
In a custom Resource handler, query is a RequestTarget, which extends URLSearchParams:
static async get(query) {
const ids = query.ids; // undefined, always, for a custom param
const ids = query.get('ids'); // correct
}
resources/RequestTarget.ts:5 — class RequestTarget extends URLSearchParams — declares only a
fixed set of framework properties (conditions, limit, select, sort, … ~:24-100). Arbitrary
query parameters are never assigned as own properties: resources/search.ts:1370's
NEEDS_PARSER = /[()[\]|!<>.]|(=\w*=)/ gates the FIQL parser, so a plain ?ids=1,2,3 (no special
characters) takes parseQuery's else branch (search.ts:1381-1406) and simply returns query
untouched.
So query.ids is undefined and there is no error — the handler quietly behaves as if the caller
sent nothing.
Why it's worth a doc callout rather than a code change
It fails silently, and it fails the same way for everyone writing their first custom Resource. It
already bit our own QA fixture: a DirectHistory test resource read query.ids and the bug stayed
invisible only because that parameter's value happened to equal the handler's default.
HarperFast/documentation reference/resources/resource-api.md:67 already shows the right form
(target.get('param1')) in an example, but nowhere states that the plain-property form silently
yields undefined. An example a reader can copy correctly is not the same as a warning a reader can
avoid; the failure mode needs naming.
Ask
In the resource-api reference, where get(query) is described:
- State that
queryis aRequestTarget extends URLSearchParams. - State that custom query parameters must be read with
query.get('name'), and that plain property
access returnsundefinedwithout error. - Note which properties are available directly (the declared framework set:
conditions,limit,
select,sort, …), so the distinction is learnable rather than a rule to memorize.
Not this
HarperFast/harper#135 ("A target should have parsed query properties in static REST methods") is
CLOSED (2026-04-15, PR #124 "Immediately parse search/queries in URLs provided to RequestTarget").
That fix made the declared special-purpose properties parse eagerly in the constructor; it never
made arbitrary custom parameter names land as own properties, and was not intended to. So this is not
covered by #135's closure — re-verified on main 6d725818c.
— Claude Opus 5.5
- 主要语言
- MDX
- 星标
- 9
- 派生
- 9
- 平均合并
- 1 天 20 小时
- 30 天内合并 PR
- 16
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
HarperFast/documentation 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
HarperFast/documentation#677 ·
维护者通常 2 天内回复
-
难度 2/5 半天 新手友好度 88/100
HarperFast/documentation#675 ·
维护者通常 2 天内回复
-
难度 1/5 1 小时以内 新手友好度 92/100
HarperFast/documentation#665 ·
维护者通常 2 天内回复
-
content
难度 2/5 1-3 小时 新手友好度 74/100
HarperFast/documentation#478 ·
维护者通常 2 天内回复
-
content
难度 1/5 1 小时以内 新手友好度 76/100
HarperFast/documentation#399 · 2 条评论 ·
维护者通常 2 天内回复
查看 HarperFast/documentation 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 85/100
mozilla/bedrock#17413 · 1 个 reaction ·
维护者通常 2 天内回复
-
automated issue report
难度 1/5 1 小时以内 新手友好度 68/100
-
documentation
难度 1/5 1 小时以内 新手友好度 92/100
github/copilot-sdk#2804 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
drizzle-team/drizzle-orm#6418 ·
维护者通常 4 天内回复
-
automated issue report
难度 2/5 1-3 小时 新手友好度 72/100
lirantal/discoprint#31 ·
维护者通常 1 天内回复