Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect Handling of Nested Includes for Missing Relationships #69

Open
cube-dainis opened this issue Jan 13, 2025 · 0 comments
Open

Comments

@cube-dainis
Copy link

cube-dainis commented Jan 13, 2025

Description:

According to the JSON:API documentation, when requesting a nested include such as destination.location for a stop resource, if the stop does not have a destination attached to it, the response should return destination=null instead of breaking with an error.

Steps to Reproduce:

  1. Create a resource location.
  2. Create a resource destination with nullable relationship location.
  3. Create a resource stop with nullable relationship destination.
  4. Request the stop resource with the include destination.location.
    (Ensure that the stop resource does not have a destination attached)

Expected Behavior:

The response should include:

"relationships": {
  "destination": {
    "data": null
  }
}

Actual Behavior:

The request fails with an error due to the missing destination resource ($this->resource):

ErrorException: Attempt to read property \"location\" on null

Linked Pull Request:

PR: #70

@cube-dainis cube-dainis changed the title Breaks when trying to access subresource of nulled resource Incorrect Handling of Nested Includes for Missing Relationships Jan 13, 2025
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

No branches or pull requests

1 participant