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

Return 409 if a tranform request is done for a restricted revision #355

Merged
merged 4 commits into from Sep 25, 2015

Conversation

Pchelolo
Copy link
Contributor

Right now if the page was deleted or a revision was restricted while it was edited in VE, transform endpoints return 400 errors, however this situation is more about an edit conflict.

@d00rman
Copy link
Contributor

d00rman commented Sep 24, 2015

LGTM. @subbuss do you think it is a good practice to return a 429 CONFLICT when a transform for a deleted page or revdeleted revision is attempted?

@@ -715,6 +715,22 @@ PSP.makeTransform = function(from, to) {
status: e.status
});
}
// In case the a page was deleted/revision restricted wkile edit was happening,
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, while it is true that the code above will disappear soon, currently it will log something other than 429 (either a 404 or a 403). Should we try to integrate these two so that we can easily match user reports with logs (which was the initial incentive to introduce this temp code) ?

Also, some small nits on this line:
s/the//
s/wkile/while/

@d00rman
Copy link
Contributor

d00rman commented Sep 24, 2015

@subbuss rightfully pointed out our mistake. 429 stands for too many requests, which has nothing to do with what we are trying to achieve here.

We have at our disposal 409 (CONFLICT), 410 (GONE) and 423 (LOCKED). Ideally, I'd vote for a 410 for deleted pages and 423 for revdeleteled revisions, but since 423 is a WebDAV code, I propose to go with 410 for deleted pages and 409 for revdeletions.

@gwicke
Copy link
Member

gwicke commented Sep 25, 2015

In both HTML save and transform end points, we already ask clients to set an If-Match header specifying the original etag (revision/timeuuid). Right now, the transform end points still provide the meta tag hack fall-back (mostly for VE's benefit), but it would be a lot cleaner (and less brittle) to phase that out in favor of working with If-Match only. A page or revision deletion would break the precondition (if provided), which we would indicate with a 412 Precondition Failed response.

@Pchelolo
Copy link
Contributor Author

@d00rman hah, we've been fighting so much with 429 codes, that it just settled in my head..

@gwicke The if-match header is parsed (required) only in html/to/* endpoints, so it might be not passed on others, like wikitext to html transformation, and this is needed on all transformations.

@Pchelolo Pchelolo changed the title Return 429 if a tranform request is done for a restricted revision Return 409 if a tranform request is done for a restricted revision Sep 25, 2015
@d00rman
Copy link
Contributor

d00rman commented Sep 25, 2015

Let's keep it like that for now, but I agree with @gwicke that in the long term 412 would be the way to go.

d00rman pushed a commit that referenced this pull request Sep 25, 2015
Return 409 if a tranform request is done for a restricted revision
@d00rman d00rman merged commit 79a7b95 into wikimedia:master Sep 25, 2015
@gwicke
Copy link
Member

gwicke commented Sep 28, 2015

@gwicke The if-match header is parsed (required) only in html/to/* endpoints, so it might be not passed on others, like wikitext to html transformation, and this is needed on all transformations.

The meta tag hack certainly does not work for wikitext, and the end point does not support passing in the timeuuid at all right now. It is also not absolutely needed, as any html/data-parsoid copy will do for incremental re-parsing, as long as it's consistent.

It would however be more consistent to move to using the ETag for wikitext as well. We can also support passing it in the POST data with a mechanism like https://phabricator.wikimedia.org/T111748.

@Pchelolo
Copy link
Contributor Author

@gwicke Actually, you've made me think that we could be handling this in a wrong way.

On html->* transforms, the tid of the original content is required now, but in case original html is not in storage, and we are generating it, we font's include that tid in request for revision info, and get the latest info version of revision info. In this particular case, the page's been deleted, so we get these errors. Shouldn't we instead get the revision info for the original tid? (the latest one before the original tid)

@gwicke
Copy link
Member

gwicke commented Sep 29, 2015

@Pchelolo, I guess you were thinking about a use case where somebody editing a now-deleted revision will still expect a successful save based on that revision? In that case, we don't really have a tid for the revision info -- all we have is the timestamp contained in that tid. It might be possible to retrieve the revision info based on that, but it's a bit icky.

The risk I see with enabling such an edit is that the revision deleted content could be perpetuated in the edit. From a user perspective, triggering an edit conflict workflow would probably make most sense, which fits with the If-Match handling.

@Pchelolo Pchelolo deleted the delete_conflict branch December 21, 2015 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants