Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Resource.get(query) receives a RequestTarget: plain property access is silently undefined

未关闭 适合新手
#690 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
1/5
预计耗时
1 小时以内
新手友好度
90/100
Issue 类型
文档
描述清晰度
描述清楚
活跃度
活跃
领域
documentation

调研方向

从 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:

  1. State that query is a RequestTarget extends URLSearchParams.
  2. State that custom query parameters must be read with query.get('name'), and that plain property
    access returns undefined without error.
  3. 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 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

HarperFast/documentation 的其他 Issue

查看 HarperFast/documentation 的全部 Issue

相似的 Issue

更多 Documentation Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。