Repository navigation
feat(webhooks): add conditional delete precondition support - #15450
hardikkaurani wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
|
Hey @eldadfux @HarshMN2345, put this together for #14354 to add optional |
Code review
Webhook DELETE now honors Note @hardikkaurani does not have write access to this repository, so Hansi does not approve automatically. A maintainer can review and approve. Walkthrough (6)
Reviewed Tip Comment |
|
Updated after the review feedback: rewrote |
|
@HarshMN2345 Please review ! |
|
Thanks for picking this up. I've updated #14354: Appwrite already has a precondition for this, Changes needed:
try {
$dbForPlatform->withRequestTimestamp($requestTimestamp, fn () => $authorization->skip(
fn () => $dbForPlatform->deleteDocument('webhooks', $webhook->getId())
));
} catch (ConflictException) {
throw new Exception(Exception::WEBHOOK_UPDATE_CONFLICT);
}
|
1a460f4 to
5d95667
Compare
|
@ChiragAgg5k Thanks for the detailed review and for updating #14354. I've rebased onto
|

Adds conditional precondition support to webhook mutations using Appwrite's existing
X-Appwrite-Timestampheader (requestTimestamp) so concurrent updates or deletes cannot silently overwrite or drop each other.Summary
requestTimestampand wrapdeleteDocument/updateDocumentwith$dbForPlatform->withRequestTimestamp($requestTimestamp, ...)in:Webhooks/Delete.phpWebhooks/Update.phpWebhooks/Secret/Update.phpUtopia\Database\Exception\Conflictand throwException::WEBHOOK_UPDATE_CONFLICT(webhook_update_conflict, HTTP409), matchingdocument_update_conflictandrow_update_conflict.ifUpdatedAtparameter,X-Appwrite-If-Updated-Atheader,WEBHOOK_PRECONDITION_FAILED, andWebhookConditionalDeleteTest.tests/e2e/Services/Webhooks/WebhooksBase.php(testWebhookRequestTimestampPreconditions) covering stale (409 webhook_update_conflict) and matching (200/204)X-Appwrite-Timestamppreconditions acrossPUT,PATCH /secret, andDELETE.Verification
php -lpassed on all 6 modified files (errors.php,Exception.php,Delete.php,Update.php,Secret/Update.php,WebhooksBase.php).Resolves #14354