Skip to content

Conversation

JamesGlover
Copy link
Contributor

@JamesGlover JamesGlover commented Jun 8, 2021

Fixes #1371

JSONAPI::ResourceTree#load_included was failing to correctly
populate the resource fragments of included resources, such that
the include_related parameter was null. This was resulting in
the relationships object lacking a data attribute for nil or
empty resources.

The JSON-API specification states that a null or empty array should
be returned in these circumstances:
https://jsonapi.org/format/#document-resource-object-linkage

The underlying issue appears to be the use of include_related rather
than the symbol :include_related when initializing nested resource
fragments.

All Submissions:

  • I've checked to ensure there aren't other open Pull Requests for the same update/change.
  • I've submitted a ticket for my issue if one did not already exist.
  • My submission passes all tests. (Please run the full test suite locally to cut down on noise from travis failures.)
  • I've used Github auto-closing keywords in the commit message or the description.
  • I've added/updated tests for this change.

New Feature Submissions:

  • I've submitted an issue that describes this feature, and received the go ahead from the maintainers.
  • My submission includes new tests.
  • My submission maintains compliance with JSON:API.

Bug fixes and Changes to Core Features:

  • I've included an explanation of what the changes do and why I'd like you to include them.
  • I've provided test(s) that fails without the change.

Test Plan:

Reviewer Checklist:

  • Maintains compliance with JSON:API
  • Adequate test coverage exists to prevent regressions

JSONAPI::ResourceTree#load_included was failing to correctly
populate the resource fragments of included resources, such that
the `include_related` parameter was null. This was resulting in
the relationships object lacking a data attribute for nil or
empty resources.

The JSON-API specification states that a null or empty array should
be returned in these circumstances:
https://jsonapi.org/format/#document-resource-object-linkage

The underlying issue appears to be the use of `include_related` rather
than the symbol `:include_related` when initializing nested resource
fragments.
@lgebhardt lgebhardt merged commit bf4b4cd into cerebris:master Aug 9, 2021
@lgebhardt
Copy link
Member

@JamesGlover Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect handling of null or empty nested includes
2 participants