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

Serializer.validate must return validated data #1432

Merged
merged 1 commit into from
May 9, 2023

Conversation

sivel
Copy link
Contributor

@sivel sivel commented May 3, 2023

It looks like way back in 357cdca, at a minimum the v2, collection upload API was broken due to the addition of a validate method that did not return the validated data:

pulp [3e989c26c1444f1abb437f8f61ac3ffe]: django.request:ERROR: Internal Server Error: /pulp_ansible/galaxy/primary/api/v2/collections/
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python3.8/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/django/views/generic/base.py", line 70, in view
    return self.dispatch(request, *args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 509, in dispatch
    response = self.handle_exception(exc)
  File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 469, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
    raise exc
  File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 506, in dispatch
    response = handler(request, *args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/pulp_ansible/app/galaxy/views.py", line 184, in post
    serializer.is_valid(raise_exception=True)
  File "/usr/local/lib/python3.8/site-packages/rest_framework/serializers.py", line 227, in is_valid
    self._validated_data = self.run_validation(self.initial_data)
  File "/usr/local/lib/python3.8/site-packages/rest_framework/serializers.py", line 430, in run_validation
    assert value is not None, '.validate() should return the validated data'
AssertionError: .validate() should return the validated data

A few things to note about tests:

  1. The pulp-ansible-client package does not provide an API for uploading collections to the v2 collections API, only v3
  2. Due to the above, afaict the tests are only testing the v3 collections API
  3. I don't know how to write tests that test the v2 collections API as a result

[noissue]

@mdellweg
Copy link
Member

mdellweg commented May 9, 2023

As this being a bug fix (obviously?), can you file and link an issue to it?

@sivel sivel force-pushed the v2-api-collection-upload-fix branch from fb4b465 to 929fcd9 Compare May 9, 2023 13:50
@sivel
Copy link
Contributor Author

sivel commented May 9, 2023

Issue created, changelog added, commits squashed

@mdellweg mdellweg merged commit 69e2017 into pulp:main May 9, 2023
@patchback
Copy link

patchback bot commented May 9, 2023

Backport to 0.16: 💚 backport PR created

✅ Backport PR branch: patchback/backports/0.16/69e20174b441bd432e982b0c970597f73a7d3d0c/pr-1432

Backported as #1442

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

@patchback
Copy link

patchback bot commented May 9, 2023

Backport to 0.17: 💚 backport PR created

✅ Backport PR branch: patchback/backports/0.17/69e20174b441bd432e982b0c970597f73a7d3d0c/pr-1432

Backported as #1443

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

patchback bot pushed a commit that referenced this pull request May 9, 2023
gerrod3 pushed a commit that referenced this pull request May 9, 2023
…1443)

(cherry picked from commit 69e2017)

Co-authored-by: Matt Martz <matt@sivel.net>
mdellweg pushed a commit that referenced this pull request May 10, 2023
mdellweg pushed a commit that referenced this pull request May 10, 2023
…lidated data (#1442)

* Serializer.validate must return validated data. Fixes #1441 (#1432)

(cherry picked from commit 69e2017)

* Fix sphinx intersphinx_mapping config. (#1439)

New value comes from https://www.sphinx-doc.org/en/master/usage/extensions/intersphinx.html#configuration

[noissue]

Signed-off-by: James Tanner <tanner.jc@gmail.com>
(cherry picked from commit ee877c0)

---------

Co-authored-by: Matt Martz <matt@sivel.net>
Co-authored-by: jctanner <tanner.jc@gmail.com>
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.

3 participants