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

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

Aperta Adatta ai principianti
#690 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
1/5
Tempo stimato
Meno di un'ora
Idoneità per principianti
90/100
Tipo di issue
Documentazione
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
javascript, typescript
Ambito
documentation

Direzione di ricerca

Inizia da reference/resources/resource-api.md, dove è descritto get(query), quindi controlla resources/RequestTarget.ts per le proprietà del framework dichiarate direttamente. Usa come contesto l'esempio esistente target.get('param1'). Il lavoro è completato quando la reference identifica esplicitamente RequestTarget come estensione di URLSearchParams, spiega query.get('name') per i parametri personalizzati e l'accesso a proprietà semplici come undefined, ed elenca le proprietà dirette.

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

Descrizione

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

Lingua principale
MDX
Stelle
9
Fork
9
Merge medio
1g 20h
PR unite (30g)
16

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 HarperFast/documentation

Tutte le issue di HarperFast/documentation

Issue simili

Altre issue su Documentation

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.