Skip to content
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

Fix Any serializer type regression breaking Ruby bindings #5936

Merged
merged 1 commit into from
Oct 29, 2024

Conversation

pedro-psb
Copy link
Member

@ianballou
Copy link

I'd like to request that 3.63 receive the back port since that's what's in the Katello 4.15 matrix.

Comment on lines 24 to 30
@extend_schema_field(OpenApiTypes.OBJECT)
class JSONObjectField(serializers.JSONField):
"""A drf JSONField override to force openapi schema to use 'object' type.

Not strictly correct, but we relied on that for a long time.
See: https://github.com/tfranzel/drf-spectacular/issues/1095
"""
Copy link
Member

Choose a reason for hiding this comment

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

Let me understand this right. It sounds like a stop gap solution. But I think we are rather close to a good solution here. Most of our JSONFields actually require an object/dict. So how about we call this thing a JSONDictField (IMHO, the domain of the problem here is rather a python dev then an OpenAPIv3 connoisseur. So I prefer Dict over Object.) and it suddenly does not sound like an accident anymore. Instead when you use that field on a serializer, you are explicit about it needing a dictionary. At the same time we just ban the use of an un-annotated plain JSONField.
(Obviously, now this means, search and replace without reviewing is a bad idea again.)

Copy link
Member Author

Choose a reason for hiding this comment

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

"Object" here is about the Json spec object structure: https://datatracker.ietf.org/doc/html/rfc7159#section-4
The correct name for this field as it is now would be JSONPrimitiveField (as drf docs calls a any-json entity), which reflects it can be any primitive.

I would like to get the fields right, which would involve switching to DictField and ListFIeld, mosly. I opened this PR on RPM which does that with some care, but the concern is that it changes/breaks the API pulp/pulp_rpm#3657 (comment).

@pedro-psb pedro-psb force-pushed the fix/type-regression-on-drf-spectacular branch from ed1fd6d to 738216c Compare October 28, 2024 17:11
@pedro-psb
Copy link
Member Author

Changed the name. Also here is the 3.63 backport: #5938

Copy link
Member

@mdellweg mdellweg left a comment

Choose a reason for hiding this comment

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

Thank you! I'd really like to make it sound less like an accident. Also we may want to export this helper in the plugin api.
That would be OK as a follow up PR.

@pedro-psb
Copy link
Member Author

Also we may want to export this helper in the plugin api.

Yeah, agree

@dralley dralley merged commit 58425d7 into pulp:main Oct 29, 2024
12 checks passed
Copy link

patchback bot commented Oct 29, 2024

Backport to 3.21: 💔 cherry-picking failed — conflicts found

❌ Failed to cleanly apply 58425d7 on top of patchback/backports/3.21/58425d791296752be427a43cda9df0d2403bc7bc/pr-5936

Backporting merged PR #5936 into main

  1. Ensure you have a local repo clone of your fork. Unless you cloned it
    from the upstream, this would be your origin remote.
  2. Make sure you have an upstream repo added as a remote too. In these
    instructions you'll refer to it by the name upstream. If you don't
    have it, here's how you can add it:
    $ git remote add upstream https://github.com/pulp/pulpcore.git
  3. Ensure you have the latest copy of upstream and prepare a branch
    that will hold the backported code:
    $ git fetch upstream
    $ git checkout -b patchback/backports/3.21/58425d791296752be427a43cda9df0d2403bc7bc/pr-5936 upstream/3.21
  4. Now, cherry-pick PR Fix Any serializer type regression breaking Ruby bindings #5936 contents into that branch:
    $ git cherry-pick -x 58425d791296752be427a43cda9df0d2403bc7bc
    If it'll yell at you with something like fatal: Commit 58425d791296752be427a43cda9df0d2403bc7bc is a merge but no -m option was given., add -m 1 as follows instead:
    $ git cherry-pick -m1 -x 58425d791296752be427a43cda9df0d2403bc7bc
  5. At this point, you'll probably encounter some merge conflicts. You must
    resolve them in to preserve the patch from PR Fix Any serializer type regression breaking Ruby bindings #5936 as close to the
    original as possible.
  6. Push this branch to your fork on GitHub:
    $ git push origin patchback/backports/3.21/58425d791296752be427a43cda9df0d2403bc7bc/pr-5936
  7. Create a PR, ensure that the CI is green. If it's not — update it so that
    the tests and any other checks pass. This is it!
    Now relax and wait for the maintainers to process your pull request
    when they have some cycles to do reviews. Don't worry — they'll tell you if
    any improvements are necessary when the time comes!

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

Copy link

patchback bot commented Oct 29, 2024

Backport to 3.22: 💔 cherry-picking failed — conflicts found

❌ Failed to cleanly apply 58425d7 on top of patchback/backports/3.22/58425d791296752be427a43cda9df0d2403bc7bc/pr-5936

Backporting merged PR #5936 into main

  1. Ensure you have a local repo clone of your fork. Unless you cloned it
    from the upstream, this would be your origin remote.
  2. Make sure you have an upstream repo added as a remote too. In these
    instructions you'll refer to it by the name upstream. If you don't
    have it, here's how you can add it:
    $ git remote add upstream https://github.com/pulp/pulpcore.git
  3. Ensure you have the latest copy of upstream and prepare a branch
    that will hold the backported code:
    $ git fetch upstream
    $ git checkout -b patchback/backports/3.22/58425d791296752be427a43cda9df0d2403bc7bc/pr-5936 upstream/3.22
  4. Now, cherry-pick PR Fix Any serializer type regression breaking Ruby bindings #5936 contents into that branch:
    $ git cherry-pick -x 58425d791296752be427a43cda9df0d2403bc7bc
    If it'll yell at you with something like fatal: Commit 58425d791296752be427a43cda9df0d2403bc7bc is a merge but no -m option was given., add -m 1 as follows instead:
    $ git cherry-pick -m1 -x 58425d791296752be427a43cda9df0d2403bc7bc
  5. At this point, you'll probably encounter some merge conflicts. You must
    resolve them in to preserve the patch from PR Fix Any serializer type regression breaking Ruby bindings #5936 as close to the
    original as possible.
  6. Push this branch to your fork on GitHub:
    $ git push origin patchback/backports/3.22/58425d791296752be427a43cda9df0d2403bc7bc/pr-5936
  7. Create a PR, ensure that the CI is green. If it's not — update it so that
    the tests and any other checks pass. This is it!
    Now relax and wait for the maintainers to process your pull request
    when they have some cycles to do reviews. Don't worry — they'll tell you if
    any improvements are necessary when the time comes!

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

Copy link

patchback bot commented Oct 29, 2024

Backport to 3.39: 💚 backport PR created

✅ Backport PR branch: patchback/backports/3.39/58425d791296752be427a43cda9df0d2403bc7bc/pr-5936

Backported as #5944

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

Copy link

patchback bot commented Oct 29, 2024

Backport to 3.28: 💚 backport PR created

✅ Backport PR branch: patchback/backports/3.28/58425d791296752be427a43cda9df0d2403bc7bc/pr-5936

Backported as #5945

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

Copy link

patchback bot commented Oct 29, 2024

Backport to 3.49: 💚 backport PR created

✅ Backport PR branch: patchback/backports/3.49/58425d791296752be427a43cda9df0d2403bc7bc/pr-5936

Backported as #5946

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

Copy link

patchback bot commented Oct 29, 2024

Backport to 3.66: 💚 backport PR created

✅ Backport PR branch: patchback/backports/3.66/58425d791296752be427a43cda9df0d2403bc7bc/pr-5936

Backported as #5947

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants