Add URL validation to operational server webhooks #1887
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
This PR addresses issue #1138 "Handling of operational webhooks server name" which was identified after users experienced problems configuring and troubleshooting operational webhooks in local development environments.
The current implementation of operational webhooks has two key issues:
The server URL provided in
SVIX_OPERATIONAL_WEBHOOK_ADDRESS
is not validated or sanitized before use, leading to problems when users provide URLs with trailing slashes or incorrect formats.When operational webhooks fail to deliver with a 404 error, the system logs a generic "Operational webhooks are enabled but no listener set for {org_id}" message, without distinguishing between different failure scenarios (e.g., incorrect URL format, missing application, or missing endpoint).
These issues make it difficult to diagnose and resolve operational webhook configuration problems, as referenced in discussion #1125 where a user couldn't get operational webhooks working locally.
Solution
This PR implements three key improvements to the operational webhooks handling:
URL Validation: Added validation for the
operational_webhook_address
configuration value incfg.rs
that verifies:URL Sanitization: Enhanced the
OperationalWebhookSenderInner::new
method inoperational_webhooks.rs
to properly sanitize URLs by:Improved Error Handling: Expanded the error handling in
send_operational_webhook
to provide more detailed diagnostics: