Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

JSON:API 1.1: return empty 'included' array when ?include= is present #1301

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

Merged
sliverc merged 5 commits into django-json-api:main from harshalkalewar:fix/include-empty-array
Aug 27, 2025

Conversation

Copy link
Contributor

@harshalkalewar harshalkalewar commented Aug 20, 2025
edited by sliverc
Loading

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

auvipy reacted with thumbs up emoji
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.
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
edited
Loading

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.

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?

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.

Copy link
Contributor Author

harshalkalewar commented Aug 27, 2025
edited
Loading

@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
Copy link
Contributor Author

harshalkalewar commented Aug 27, 2025
edited
Loading

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

sliverc reacted with thumbs up emoji sliverc reacted with hooray emoji

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@sliverc sliverc sliverc approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

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

AltStyle によって変換されたページ (->オリジナル) /