From 59d92a1f1525e483af0f7ce89e18cf6a84d2b61b Mon Sep 17 00:00:00 2001 From: Andre Klapper Date: Sun, 26 Oct 2025 11:31:17 +0100 Subject: [PATCH] Raise Webhook URI length limit from 255 to 2048 Summary: 2048 is arbitrary (as 255 was) and only enforced in the UI but not on a DB level. Closes T16303 Test Plan: * Run `./bin/storage upgrade` * Check `./bin/storage status` * Check `EXPLAIN phabricator_herald.herald_webhook;` and/or http://phorge.localhost/config/database/localhost/phabricator_herald/herald_webhook/ before and after * Go to http://phorge.localhost/herald/webhook/edit/form/default/ and enter a long URI in the `URI` field before and after Reviewers: O1 Blessed Committers, avivey Reviewed By: O1 Blessed Committers, avivey Subscribers: avivey, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T16303 Differential Revision: https://we.phorge.it/D26462 --- resources/sql/autopatches/20251024.herald.webhookuri.sql | 2 ++ src/applications/herald/storage/HeraldWebhook.php | 2 +- .../herald/xaction/HeraldWebhookURITransaction.php | 6 +++--- 3 files changed, 6 insertions(+), 4 deletions(-) create mode 100644 resources/sql/autopatches/20251024.herald.webhookuri.sql diff --git a/resources/sql/autopatches/20251024.herald.webhookuri.sql b/resources/sql/autopatches/20251024.herald.webhookuri.sql new file mode 100644 index 0000000000..df60f1aae6 --- /dev/null +++ b/resources/sql/autopatches/20251024.herald.webhookuri.sql @@ -0,0 +1,2 @@ +ALTER TABLE {$NAMESPACE}_herald.herald_webhook + MODIFY COLUMN webhookURI LONGTEXT NOT NULL; diff --git a/src/applications/herald/storage/HeraldWebhook.php b/src/applications/herald/storage/HeraldWebhook.php index 0101dbef52..fd71980185 100644 --- a/src/applications/herald/storage/HeraldWebhook.php +++ b/src/applications/herald/storage/HeraldWebhook.php @@ -24,7 +24,7 @@ final class HeraldWebhook self::CONFIG_AUX_PHID => true, self::CONFIG_COLUMN_SCHEMA => array( 'name' => 'text128', - 'webhookURI' => 'text255', + 'webhookURI' => 'text', 'status' => 'text32', 'hmacKey' => 'text32', ), diff --git a/src/applications/herald/xaction/HeraldWebhookURITransaction.php b/src/applications/herald/xaction/HeraldWebhookURITransaction.php index e0162085cb..55c1cb69de 100644 --- a/src/applications/herald/xaction/HeraldWebhookURITransaction.php +++ b/src/applications/herald/xaction/HeraldWebhookURITransaction.php @@ -4,6 +4,7 @@ final class HeraldWebhookURITransaction extends HeraldWebhookTransactionType { const TRANSACTIONTYPE = 'uri'; + private $webhookURIMaxLength = 2048; public function generateOldValue($object) { return $object->getWebhookURI(); @@ -40,17 +41,16 @@ final class HeraldWebhookURITransaction return $errors; } - $max_length = $object->getColumnMaximumByteLength('webhookURI'); foreach ($xactions as $xaction) { $old_value = $this->generateOldValue($object); $new_value = $xaction->getNewValue(); $new_length = strlen($new_value); - if ($new_length > $max_length) { + if ($new_length > $this->webhookURIMaxLength) { $errors[] = $this->newInvalidError( pht( 'Webhook URIs can be no longer than %s characters.', - new PhutilNumber($max_length)), + new PhutilNumber($this->webhookURIMaxLength)), $xaction); } -- 2.51.2