Skip to content

#7703 adding deprecations to release notes #7716

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
merged 2 commits into from
Mar 9, 2021
Merged

#7703 adding deprecations to release notes #7716

merged 2 commits into from
Mar 9, 2021

Conversation

nathanglover
Copy link
Contributor

@nathanglover nathanglover commented Feb 14, 2021

Closes #7703

Adding the detail_route and list_route deprecations to the 3.10.x release notes. Let me know if I need to update the format at all.

Copy link
Member

@auvipy auvipy left a comment

Choose a reason for hiding this comment

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

this is good addition i believe

@xordoquy
Copy link
Collaborator

Hi, thanks for the contribution.

Could you rename the link as [gh6687] and add [gh6687]: https://github.com/encode/django-rest-framework/issues/6687 around the bottom of the page in the 3.10 link section please ?

@nathanglover
Copy link
Contributor Author

Sure thing. Completed in the most recent commit.

@Syntaf
Copy link

Syntaf commented Feb 19, 2021

Thanks for taking the reigns on getting this PR done @nathanglover

Another breaking change I found relates to https://github.com/encode/django-rest-framework/pull/6659/files , which fixes a bug but causes None values to be ran through a fields validation and not short-circuted.

Essentially, if you're currently overriding to_internal_value on a base serializer class and handling the case where not field.source_attrs and validated_value is None, DRF versions after 3.9.X will break this fix.

Example:

class BaseModelSerializer(serializers.ModelSerializer):
  def to_internal_value(self, data):
    # ...
    for field in fields:
      # ...
      try:
          validated_value = field.run_validation(primitive_value)
          if validate_method is not None:
              validated_value = validate_method(validated_value)
      except ValidationError as exc:
          errors[field.field_name] = exc.detail
      except DjangoValidationError as exc:
          errors[field.field_name] = list(exc.messages)
      except SkipField:
          pass
      else:
          if not field.source_attrs and validated_value is None:
            # custom solution to correctly set field
          else:
            set_value(ret, field.source_attrs, validated_value)

Although it took me quite awhile to understand why this broke for us, it's a pretty deep edge case that's arguably our fault for toying with DRF internals.

Even so, if you all agree, I might recommend we change:

  • Fix nullable fields with source="*"

To

  • Fix nullable fields with source="*"

    Possible backwards compatibility break if you were previously relying on these fields to skip validation when receiving None, you will need to override your field's to_internal_value to short-circuit values of None to avoid any validation rules

I can submit a follow-up PR for this if needed

@tomchristie
Copy link
Member

Looks good thanks @nathanglover.

@tomchristie tomchristie merged commit a89a642 into encode:master Mar 9, 2021
stefanacin pushed a commit to stefanacin/django-rest-framework that referenced this pull request Mar 22, 2021
* encode#7703 adding deprecations to release notes

* encode#7703 - update link for gh6687
sigvef pushed a commit to sigvef/django-rest-framework that referenced this pull request Dec 3, 2022
* encode#7703 adding deprecations to release notes

* encode#7703 - update link for gh6687
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.

Missing breaking change notice in 3.10.X release notes
6 participants