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 addon PUT as full-update or create #19342

Merged
merged 4 commits into from
Jun 13, 2022

Conversation

eviljeff
Copy link
Member

@eviljeff eviljeff commented Jun 8, 2022

fixes mozilla/addons#7908

This allows submission of all types of add-on, not just langpacks (as mozilla/addons#7908 talks about), but should we limit PUT on addon/<slug>/ to just langpacks as per issue? Pros: The existing signing API allowed this style PUT to create or update so it'd be restoring that functionality. Cons: it's generally not a "good idea" to have an API where you don't know what the request will do - it could create a new version for an existing add-on, or it could create a new add-on - both outcomes could be a surprise if you weren't expecting it. There's also some subtle differences around metadata in the manifest (the name, description, and homepage would be extracted for a new add-on; they wouldn't be for a new version) which are non-obvious.

Another feature this patch restores from the signing API (partially) is the ability to specify the GUID via the url if it's not in the manifest. Pros: It's a convenient feature; Cons: it's against the direction of travel regarding future changes to require the manifest specify the guid explicitly so it's possibly unwise to encourage that use.

Note: the issue talks about auto-generating the summary + license + category for a langpack - the patch doesn't do that as it's now trivial for the client to supply this in the POST data.

@eviljeff eviljeff force-pushed the 15353-api-lang-pack-submit branch from f36cfee to 2b5d2d1 Compare June 8, 2022 17:24
@eviljeff eviljeff force-pushed the 15353-api-lang-pack-submit branch from 2b5d2d1 to e484af6 Compare June 9, 2022 17:10
@eviljeff eviljeff marked this pull request as ready for review June 9, 2022 18:36
@eviljeff eviljeff requested review from a team and diox and removed request for a team June 9, 2022 19:05
Comment on lines 386 to 390
serializer = self.get_serializer(data=request.data)
serializer.is_valid(raise_exception=True)
serializer.save(guid=self.kwargs['guid'])

return Response(serializer.data, status=status.HTTP_201_CREATED)
Copy link
Member

Choose a reason for hiding this comment

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

Couldn't you use self.create(request, *args, **kwargs) here instead ?

Copy link
Member

Choose a reason for hiding this comment

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

And, related to that... wouldn't self.action be incorrect here with your current code ?

Copy link
Member Author

Choose a reason for hiding this comment

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

It is possible to use self.create (and I almost did) but we'd need to override the save method to include guid (and either check the action in there so we only did it for PUT) so I didn't think it helped much. I can though?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not following what you mean about self.action - can you expand on it and/or include an example scenario?

Copy link
Member

Choose a reason for hiding this comment

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

When you reach this code, self.action is still update, but we're doing a creation

Copy link
Member

Choose a reason for hiding this comment

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

It is possible to use self.create (and I almost did) but we'd need to override the save method to include guid (and either check the action in there so we only did it for PUT) so I didn't think it helped much. I can though?

No, you're right, it's not worth it.

Copy link
Member Author

Choose a reason for hiding this comment

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

When you reach this code, self.action is still update, but we're doing a creation

mmm, yeah. I think by that point the use of self.action is over, and the criteria applied for update tends to be stricter than create anyway, but I should update self.action I guess.

Copy link
Member Author

Choose a reason for hiding this comment

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

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.

Add an API for releng to submit entirely new locales
2 participants