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

implement new uploads to the addon api, for listed too. #17914

Merged
merged 2 commits into from
Oct 4, 2021

Conversation

eviljeff
Copy link
Member

@eviljeff eviljeff commented Sep 15, 2021

fixes mozilla/addons#5348 ... or the base work for it at least. (draft PR was #17765 - copied text over from it)

Basic flow:

  1. Upload the file to be validated via POSTing to api/v5/addons/submission/ to create a FileUpload (returns a serialized response that contains the upload UUID). Upload was added in implement fileupload api, part of new addon submisison api #17919.
  2. with a valid upload, submit it as a new addon to api/v5/addons/addon/ with json like {"categories": {"firefox": ["bookmarks"]}, "version": {"upload": "<uuid>", "license": 7}}
  3. or can be submitted as a new version to an existing addon via api/v5/addons/addon/<addon slug or id or guid>/versions/ with json like {"upload": "<uuid>", "license": 7}

Known limitations:

  • you can only select from pre-defined licenses - and only by specifying a numeric license id. So worked needed to:
    • implement the ability to create a custom license
    • select from predefined licenses by slug or some other mnemonic
    • maybe make the field optional (for listed versions only?) and default to all rights reserved, or the previous license for subsequent versions
  • categories are required to create an add-on but aren't really needed unless the add-on has listed versions
  • For the first listed version we want to require all the necessary metadata (name, summary, categories, version license) being defined if not available in the manifest, but not really for unlisted versions. This will necessitate some refactoring - probably moving some validation from AddonSerializer to VersionSerializer.
  • source code submission isn't implemented
  • there are some fields on AddonSerializer that should be writable but are currently either SerializerMethodFields or custom Fields/Serializers that don't have a working write implementation.
  • setting default_locale did unexpected things during Addon creation with respect to data in the manifest so left it read only.
  • Only CreateModelMixin has been added to the views to limit the scope of the changes/tests. The serializers should handle updates without a massive amount of extra work (in theory!).
  • probably many other things

@eviljeff eviljeff requested a review from diox September 15, 2021 16:34
@eviljeff

This comment has been minimized.

@eviljeff eviljeff force-pushed the 7811-addon-submission-api branch from 4a5296d to 2f330e6 Compare September 23, 2021 12:40
@eviljeff

This comment has been minimized.

Copy link
Member

@diox diox left a comment

Choose a reason for hiding this comment

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

Good first stab at it! We should capture all those TODOs and known limitations in an issue (or several...) for follow-up.

@@ -183,6 +187,7 @@ class AddonViewSet(RetrieveModelMixin, GenericViewSet):
AllowUnlistedViewerOrReviewer,
),
]
authentication_classes = [JWTKeyAuthentication, WebTokenAuthentication]
Copy link
Member

Choose a reason for hiding this comment

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

It's probably safe to do (ultimately this doesn't let you do that much), but this makes the whole API available with external auth and should be documented.

Copy link
Member Author

Choose a reason for hiding this comment

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

Documented in the API docs? Or elsewhere

Copy link
Member

Choose a reason for hiding this comment

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

In the API docs. For addons (and many others), we currently say The only authentication method available at the moment is the internal one. and this wouldn't be true anymore after these changes.

Copy link
Member

Choose a reason for hiding this comment

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

The only thing needed is to remove that whole sentence for addons API I think.

):
# Permissions are always checked against the parent add-on in
# get_addon_object() using AddonViewSet.permission_classes so we don't need
# to set any here. Some extra permission classes are added dynamically
# below in check_permissions() and check_object_permissions() depending on
# what the client is requesting to see.
permission_classes = []
authentication_classes = [JWTKeyAuthentication, WebTokenAuthentication]
Copy link
Member

Choose a reason for hiding this comment

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

As above

from olympia.signing.views import VersionView # circular import

# TODO: consolidate/replicate this behaviour.
VersionView().check_throttles(request)
Copy link
Member Author

Choose a reason for hiding this comment

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

version = Version.from_upload(
upload=upload,
addon=self.addon or validated_data.get('addon'),
# TODO: change Version.from_upload to take the compat values into account
Copy link
Member Author

Choose a reason for hiding this comment

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

@eviljeff
Copy link
Member Author

eviljeff commented Oct 4, 2021

Filed follow-ups and created a project to hold them: https://github.com/orgs/mozilla/projects/174

@eviljeff eviljeff merged commit ff32191 into mozilla:master Oct 4, 2021
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.

Upload/submit a new listed add-on version through the API
2 participants