JSONAPI-Resources / JSONAPI-Resources/jsonapi-resources
JR 0.9 ignores #records_for, crashes from nonstandard #records
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Ruby
- Sterne
- 2.3k
- Forks
- 546
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Es werden keine Dateien oder Tests genannt. Beginne damit, den include/preload-Pfad nachzuverfolgen, der die #records der zugehörigen Ressource aufruft, und vergleiche ihn anschließend mit dem dokumentierten #records_for-Hook sowie der Behandlung fehlender Zuordnungs-IDs. Fertig ist die Änderung, wenn der vorgesehene Hook verwendet wird und nicht vorhandene zugehörige Datensätze nicht mehr die Ausnahme bei der Preload-Suche verursachen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- ruby
- Bereich
- api, backend
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100