-
Notifications
You must be signed in to change notification settings - Fork 132
Core 3.70 compatibility #3876
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
Core 3.70 compatibility #3876
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,7 +22,6 @@ | |
| ) | ||
| from pulpcore.plugin.util import get_domain, resolve_prn | ||
| from rest_framework import serializers | ||
| from pulp_rpm.app.fields import CustomJSONField | ||
|
|
||
| from pulp_rpm.app.constants import ( | ||
| ALLOWED_CHECKSUM_ERROR_MSG, | ||
|
|
@@ -147,11 +146,26 @@ class RpmRepositorySerializer(RepositorySerializer): | |
| ), | ||
| read_only=True, | ||
| ) | ||
| repo_config = CustomJSONField( | ||
| repo_config = serializers.JSONField( | ||
| required=False, | ||
| help_text=_("A JSON document describing config.repo file"), | ||
| ) | ||
|
|
||
| def to_representation(self, instance): | ||
| data = super().to_representation(instance) | ||
| # Import workflow may cause these fields to be stored as "" in the database | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a separate codepath that ought to be adjusted here? Anything to fix with a data migration? Ideally we want total consistency w/ how values are stored in a field.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My understanding is that we can fix import-export workflow to ensure it stores null values and add migration to fix empty strings. I can open an issue for that. |
||
| # This ensure the correct type of None | Enum in the response | ||
| for field in ( | ||
| "checksum_type", | ||
| "metadata_checksum_type", | ||
| "package_checksum_type", | ||
| "compression_type", | ||
| ): | ||
| field_data = data.get(field) | ||
| if field_data == "": | ||
| data[field] = None | ||
| return data | ||
|
|
||
| def validate(self, data): | ||
| """Validate data.""" | ||
| for field in ("checksum_type", "metadata_checksum_type", "package_checksum_type"): | ||
|
|
@@ -410,7 +424,7 @@ class RpmPublicationSerializer(PublicationSerializer): | |
| ), | ||
| read_only=True, | ||
| ) | ||
| repo_config = CustomJSONField( | ||
| repo_config = serializers.JSONField( | ||
| required=False, | ||
| help_text=_("A JSON document describing config.repo file"), | ||
| ) | ||
|
|
@@ -549,7 +563,7 @@ class CopySerializer(ValidateFieldsMixin, serializers.Serializer): | |
| A serializer for Content Copy API. | ||
| """ | ||
|
|
||
| config = CustomJSONField( | ||
| config = serializers.JSONField( | ||
| help_text=_( | ||
| dedent( | ||
| """\ | ||
|
|
||
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.
Can you explain the distinction between
serializers.JSONField,JSONDictField, andJSONListField?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.
serializers.JSONField(drf) accept any json type (bool, str, object, array, ...) and has openapi typeany.JSONDictField(custom) validates it's a json object (aka dict) and has openapi typeobject.JSONListField(custom) validates it's a json array (aka list) and has openapi typearray.2 and 3 subclasses from 1 and then adds the layer of validation.
But actually I found that my implementation of 2 and 3 is wrong.
I should either:
a) add the correct version of these fields here to get the types and validation right
b) use the serializers.JSONField which will change the types we use in openapi to
any(which will probably not break ruby bindings this time because the new bindindg generator image probably supports any type)Uh oh!
There was an error while loading. Please reload this page.
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.
B) is what the python plugin just did I believe
pulp/pulp_python#791
Uh oh!
There was an error while loading. Please reload this page.
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.
yes, I'll do that here as there is already a lot going on