Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Expansion drops Annotations that carry multiple bodies

Aperta
#288 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
javascript
Ambito
api, backend

Direzione di ricerca

Inizia con controllers/crud.js e assertionsFrom(), poi esamina expand() e findLeafAnnotationsFor() in controllers/gog.js e la gestione della risposta Annotations-Merged. Determina come devono essere trattati i body di array e di oggetti con più chiavi e assicurati che l’espansione e il conteggio dei merge coincidano; il payload non indica alcun percorso di test, quindi il completamento dovrebbe includere la coverage del comportamento descritto.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
JavaScript
Stelle
3
Fork
6
Merge medio
4g 9h
PR unite (30g)
5

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di CenterForDigitalHumanities/rerum_server_nodejs

Tutte le issue di CenterForDigitalHumanities/rerum_server_nodejs

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.