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

Expansion drops Annotations that carry multiple bodies

未关闭
#288 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
冷清
技术栈
javascript
领域
api, backend

调研方向

从 controllers/crud.js 和 assertionsFrom() 开始,然后检查 controllers/gog.js 中的 expand()、findLeafAnnotationsFor() 以及 Annotations-Merged 响应处理。明确应如何处理数组 body 和多键对象 body,并确保展开结果与 merge 计数一致;payload 未指定测试路径,因此完成时应包含对所述行为的覆盖。

由索引模型根据 Issue 内容生成。

描述

Split out of the static review of #286 so it does not block that PR.

What happens now

assertionsFrom() in controllers/crud.js returns early on an Array body:

if (!body || typeof body !== "object" || Array.isArray(body)) return assertions

An Annotation carrying multiple bodies is still gathered by findLeafAnnotationsFor() and still counted in the Annotations-Merged response header, but contributes nothing to the expanded entity. From the client's side that reads as a nonzero merge count with no merged data.

expand() in controllers/gog.js now skips them explicitly too (added in #286 — previously a one element Array body merged onto the entity under the key "0").

Why it matters

The W3C model explicitly allows multiple bodies, and each element is usually an ordinary single-key assertion rather than a structural construct. Real examples already in annotationStore.alpha:

[{"contributor":{"label":"Dunbar, Paul Laurence","id":"http://viaf.org/viaf/76335432"}},
 {"issued":"1895-04-17"},
 {"identifier":"Box 1, F1"},
 {"uri":"https://udspace.udel.edu/handle/..."}]

Current impact: none

Measured against production at the time of the #286 review:

  • 911 leaf Annotations have an Array body
  • 0 of them target a rerum.io/v1/id/ URI under any of the six keys in TARGET_KEYS

Since /v1/id/:_id/expanded only expands RERUM-stored entities, nothing reachable through the endpoint is affected today. This is a gap that surfaces the first time an app writes a multi-body Annotation onto a RERUM entity.

Possible approach

Each element is typically itself a single assertion, so the existing logic handles them if it recurses:

if (Array.isArray(body)) {
    for (const one of body) assertions.push(...assertionsFrom({ body: one }))
    return assertions
}

Worth deciding at the same time:

  • whether Annotations-Merged should count Annotations gathered or Annotations that actually contributed an assertion
  • whether controllers/gog.js expand() should follow, or stay on single-body-only for its DEER-shaped valueObject wrapping

Related

Multi-key object bodies (not Arrays) are also dropped whole rather than partially, by the keys.length !== 1 check. Only 1 such document exists in production, so it was not worth acting on separately, but it is the same design question.

Reference

主要语言
JavaScript
星标
3
派生
6
平均合并
4 天 9 小时
30 天内合并 PR
5

环境准备

从这里开始

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

CenterForDigitalHumanities/rerum_server_nodejs 的其他 Issue

查看 CenterForDigitalHumanities/rerum_server_nodejs 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

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