Skip to content

fix(web): resolve webhook registration failure for operations with hy… - #2344

Merged
lbroudoux merged 2 commits into
microcks:masterfrom
shellyco-code:fix-webhook-registration
Oct 1, 2026
Merged

lbroudoux merged 2 commits into
microcks:masterfrom
shellyco-code:fix-webhook-registration

Conversation

@shellyco-code

Copy link
Copy Markdown
Contributor

Description

Fixes an issue where webhook registration in WebhookController fails for operations whose names contain hyphens (-) or slashes (/).

Fixes #2343

Root Cause

  1. WebhookController.registerToWebhook parsed operationId using .split("-") and checked parts.length != 2. For operation names with hyphens (e.g., order-placed-event WEBHOOK), this produced 3+ parts, resulting in an immediate 404 ("OperationId is invalid").
  2. The UI client (webhook.service.ts) encodes slashes / as ! (encodeOperationId()) to avoid routing issues in URL paths. However, WebhookController did not decode ! back to /, causing op.getName().equals(operationName) to fail and findByOperationId / countByOperationId to query mismatched identifiers.

Changes Made

  • Updated WebhookController.java:
    • Replaced .split("-") with indexOf('-') to cleanly separate serviceId from operationName.
    • Added null check on rawOperationId.
    • Decoded ! back to / in operationName during registration.
    • Decoded ! back to / in listWebhookRegistrationsForOperation and countWebhookRegistrationsForOperation.
  • Added unit tests in WebhookControllerTest.java verifying:
    • Standard operations
    • Operations with hyphens
    • Operations with encoded slashes
    • Invalid/null operationId error handling
    • Missing service and missing operation error handling
    • List and count endpoint decoding
    • Unregister endpoint

Testing & Validation

  • Verified with Maven: mvn test -Dtest=WebhookControllerTest (10 tests run, 0 failures, 0 errors).
  • Clean code formatting applied via mvn spotless:check -pl webapp (0 violations).

AI Contribution Disclosure

In accordance with the Microcks AI Contribution Policy, this contribution was developed with the assistance of an AI coding assistant. The code changes, architecture, and tests were reviewed and verified for correctness. No AI commit trailers are included.

@utafrali utafrali left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The fix is correct and complete: using indexOf('-') cleanly separates serviceId from operation name regardless of how many hyphens the name contains, and the ! to / decoding is consistently applied across all three affected endpoints. Test coverage is thorough. Two minor issues: wrong @author tag in the new test file, and no explicit guard or test for an operationId starting with -.

@lbroudoux lbroudoux left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Thanks @shellyco-code for the good catch and the contribution!

@lbroudoux
lbroudoux merged commit da2cb1f into microcks:master Oct 1, 2026
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(web): WebhookController fails to register webhooks for operations containing hyphens or slashes

3 participants