JSONAPI-Resources / JSONAPI-Resources/jsonapi-resources

JR 0.9 ignores #records_for, crashes from nonstandard #records

Aperta
#1,000 9 commenti 2 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Type: Bug
Lingua principale
Ruby
Stelle
2.3k
Fork
546
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

We've moved our main app to JR 0.9 (yay caching!) but are facing an issue where #records_for isn't being called to get associated records for a request with include param. Instead, the associated resource's #records method is being called.

I'm inclined to call this a regression, honestly, since #records_for is still documented as a potential hookup location for authorization code. I was actually just about to override this so that certain associations would ignore our authorization code, and found that it wasn't being called at all.

It doesn't appear to be a security issue for us (due to the way our authorization works), but this behavior could potentially cause security issues in other apps, depending on how they are architected (namely, if their #records_for authorized differently from their #records)

Strongly related: if the #records call on the associated resource causes some of the associations to be nonexistent, it causes an exception, since it can't find the ID of the associated record in the Hash it's built up for preload data

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

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.

Direzione di ricerca

Non sono indicati file o test. Inizia tracciando il percorso include/preload che chiama #records della risorsa associata, quindi confrontalo con l’hook #records_for documentato e con la gestione degli ID di associazione mancanti. Il lavoro è completato quando viene usato l’hook previsto e i record associati inesistenti non causano più l’eccezione nella ricerca di preload.

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

Valutazione

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

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.