Skip to content

Conversation

harshalkalewar
Copy link
Contributor

@harshalkalewar harshalkalewar commented Aug 20, 2025

Fixes #1109

This PR fixes handling of the included array so that it correctly respects both JSONAPIMeta.included_resources defaults and explicit include query parameters.

Description of the Change

  • Simplified the renderers.py logic to handle empty included arrays correctly using if included_resources:.
  • Added and adjusted test cases in test_includes.py to verify:
  • Updated failing test_search_keywords to expect an empty included array in line with default includes

Checklist

  • PR only contains one change (considered splitting up PR)
  • unit-test added
  • documentation updated
  • CHANGELOG.md updated (only for user relevant changes)
  • author name in AUTHORS

Fixes django-json-api#1109. Ensures top-level 'included' is returned as [] when the query param
?include= is provided but no related resources exist. Updates integration tests
to reflect JSON:API v1.1 spec compliance.
@harshalkalewar
Copy link
Contributor Author

Fixed tox lint config issue. Also, verified locally with tox -e lint and all checks passing.

Copy link
Member

@sliverc sliverc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this PR.

I would recommend being careful when you use AI. Always verify what it does, before accepting it.

For instance the pull request template and its checklist is actually made for human beings and not AI.

In the checklist it states to add changelog entry and add yourself to authors. Great if you could follow up on those.

Let me know if you have any questions.

@harshalkalewar
Copy link
Contributor Author

Thanks for the feedback @sliverc. I’ll make sure to review my changes instead of relying on AI.
Regarding the failing test i.e. test_search_keywords, i noticed it fails because included: [] is now always present. should i update the test to match this new behavior, or should i adjust the implementation to keep the previous behavior?

@sliverc
Copy link
Member

sliverc commented Aug 26, 2025

Thanks for following up. You need to adjust the test_search_keywords test because this test relies on a view which has default included resources, so there should be an empty-included array.

@harshalkalewar
Copy link
Contributor Author

harshalkalewar commented Aug 27, 2025

@sliverc you can let me know if you expect any changes to be made further.

Copy link
Member

@sliverc sliverc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There were some not necessary new lines added which I reverted, it looks good now and ready for merging. Thanks for your work on this.

@sliverc sliverc merged commit 88721b9 into django-json-api:main Aug 27, 2025
9 checks passed
@harshalkalewar
Copy link
Contributor Author

harshalkalewar commented Aug 27, 2025

@sliverc thanks for helping me make my first open source contribution! Looking forward to connect with you linkedin.

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.

JSON API 1.1: return included array even if nothing is included
2 participants