-
Notifications
You must be signed in to change notification settings - Fork 301
Avoid exception when trying to include skipped relationship #453
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #453 +/- ##
==========================================
+ Coverage 95.6% 95.64% +0.03%
==========================================
Files 55 55
Lines 2843 2845 +2
==========================================
+ Hits 2718 2721 +3
+ Misses 125 124 -1
Continue to review full report at Codecov.
|
Not quite clear what is happening would also need to do more investigation. I think it would be important to be able to reproduce this in a DJA test as well before merging this change as otherwise the error might occur in the future again after the next refactoring. In terms of #412 has only been introduced in version 2.5.0. Can you confirm that the issue also exists in version 2.4.0 or not? This way we at least know whether it is a regression or not. |
@sliverc based on the changelog, it looks like it is a regression: I will try to replicate the issue as part of a test case. |
@stas Have you been able to investigate this issue further? It would be great to see what causes this regression. |
@SilverC, apologies for the late reply! I reviewed again the latest version and the issue persists. I have a model with a polymorphic relationship which I need to serialize only if a specific polymorphic type of relationship is present. Using the Latest commit includes a test case. To be honest, I'd expect that the |
Thanks for looking into this again. I am bit confused that CI is green whereas the reproducible test should actually fail in my opinion showing what the error is. Or am I missing something here? In terms of |
The fix is included in 8856e0f |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😄 of course I have only looked at the last commit...
In general the change and test looks good. Some small nitpicks. And it would also be good if you could adjust AUTHORS file if desired and add a changelog entry.
It can happen when `rest_framework.fields.SkipField` is called.
@sliverc please let me know if there's anything else I can help with to get it merged. Thank you! |
Merged. Thanks for your contribution. |
Fixes
It is a very weird error I hit. We are using the DRF-JSONAPI to build
https://github.com/occrp/id-backend
One of the packages we use is django-simple-activity. Where this package provides a model with a polymorphic relationship which we renamed in our project based on the relationship type:
https://github.com/occrp/id-backend/blob/master/api_v3/serializers/action.py#L55-L62
I get a strange error when I try to include dynamically in the payload the renamed relationships.
Description of the Change
I tracked down the error here:
https://github.com/django-json-api/django-rest-framework-json-api/blob/master/rest_framework_json_api/renderers.py#L356
I was not able to reproduce it as part of the DRF-JSONAPI test suite, unfortunately (the most related changes set is #412). I'll be more than happy to provide some tests if you could direct me or just explain a bit the purpose of the
extract_included()
arguments... Maybe I'm doing something wrong.Checklist
CHANGELOG.md
AUTHORS
Thanks in advance for any help or for reviewing this!!!