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

Verified in all fields whether reserved field names are used #992

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
n2ygk merged 1 commit into django-json-api:master from sliverc:invalid_type_name
Oct 8, 2021

Conversation

Copy link
Member

@sliverc sliverc commented Oct 6, 2021
edited
Loading

Follow up of #987

Description of the Change

In meta class only specifically declared fields in serializer are accessible. In case of ModelSerializer fields may be just on the model or a user has overwritten what fields are being returned during runtime and DJA won't notice. So there does not seem to be another way then simply hooking into the get_fields method to check for reserved field names.

Not ideal but still better to have a proper exception message during runtime then as it was before where a cryptic exception was raised.

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

@sliverc sliverc requested a review from n2ygk October 6, 2021 18:58
Copy link

codecov bot commented Oct 6, 2021
edited
Loading

Codecov Report

Merging #992 (5e3169b) into master (ee679ee) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@ Coverage Diff @@
## master #992 +/- ##
=======================================
 Coverage 96.84% 96.84% 
=======================================
 Files 65 65 
 Lines 3929 3929 
=======================================
 Hits 3805 3805 
 Misses 124 124 
Impacted Files Coverage Δ
tests/test_serializers.py 100.00% <ø> (ø)
example/serializers.py 89.61% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ee679ee...5e3169b. Read the comment docs.

In meta class only specifically declared fields in serializer are accessible.
In case of `ModelSerializer` fields may be just on the model or
if a user has overwritten what fields are being returned during runtime
DJA won't notice. So there does not seem to be another way then simply hooking
into the `get_fields` method to check for reserved field names.
@n2ygk n2ygk merged commit e17ea57 into django-json-api:master Oct 8, 2021
@sliverc sliverc deleted the invalid_type_name branch October 8, 2021 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@n2ygk n2ygk n2ygk approved these changes

+1 more reviewer

@auvipy auvipy auvipy approved these changes

Reviewers whose approvals may not affect merge requirements
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

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