Claus Ibsen created CAMEL-27646:
-----------------------------------

             Summary: camel-webhook: webhookPath ignored for WhatsApp, endpoint 
webhookComponentName unchecked
                 Key: CAMEL-27646
                 URL: https://issues.apache.org/jira/browse/CAMEL-27646
             Project: Camel
          Issue Type: Bug
          Components: camel-webhook
            Reporter: Claus Ibsen
             Fix For: 4.24.0


Found while improving the option descriptions of camel-webhook for CAMEL-23832 
(commit 
https://github.com/apache/camel/commit/2b83a6b6242b3d255597fee379d4421e5ffa9d27).
These are separate problems of the component; the descriptions commit only 
documents the current behavior.

h4. 1. webhookPath has no effect for WhatsApp
{{WebhookComponent.createEndpoint()}} binds the webhook options of the URI to 
the {{WebhookConfiguration}}, and only the remaining parameters are passed on 
to the delegate endpoint. So {{webhookPath}} in 
{{webhook:whatsapp:123?webhookPath=my/path}} never reaches the WhatsApp 
endpoint. Then {{WhatsAppEndpoint.setWebhookConfiguration()}}, called from 
{{WebhookEndpoint.afterPropertiesConfigured()}}, overwrites the {{webhookPath}} 
of the webhook configuration with the {{webhookPath}} of the WhatsApp 
configuration:
{code:java}
webhookConfiguration.setWebhookPath(configuration.getWebhookPath());
{code}
The WhatsApp value is always its default {{camel-whatsapp/webhook}}, as 
whatsapp has no component option for it. The user sees the webhook exposed at 
{{camel-whatsapp/webhook}} whatever {{webhookPath}} is set to; only 
{{webhookBasePath}} changes the path.
Proposed change: in {{WhatsAppEndpoint.setWebhookConfiguration()}}, only use 
the WhatsApp {{webhookPath}} when the webhook configuration has none, or 
document that the WhatsApp {{webhookPath}} option is the only one that applies 
and make it reachable from a {{webhook:}} URI.

h4. 2. webhookComponentName set on the endpoint is not used to check the REST 
configuration
{{WebhookComponent.createEndpoint()}} calls 
{{CamelContextHelper.getRestConfiguration(getCamelContext(), 
config.getWebhookComponentName())}} on the copy of the component configuration, 
before {{setProperties(endpoint, parameters)}} applies the endpoint options. 
That call fails when the REST configuration of the CamelContext names another 
component. With {{webhookComponentName}} set on the endpoint, this check uses 
the component value (usually none) and passes, while 
{{WebhookUtils.locateRestConsumerFactory()}} later uses the endpoint value. The 
user gets no error when the endpoint names another REST component than the REST 
configuration, and the URL made by 
{{WebhookConfiguration.computeServerUriPrefix()}} then comes from the host and 
port of a REST configuration meant for the other component.
Proposed change: do the REST configuration lookup and check after the endpoint 
options are set, for example in {{WebhookEndpoint.afterPropertiesConfigured()}}.

h4. 3. The doc page does not list ClickUp
{{webhook-component.adoc}} lists Telegram and WhatsApp as the components that 
provide webhook endpoints. {{ClickUpEndpoint}} also implements 
{{WebhookCapableEndpoint}}.
Proposed change: add {{xref:clickup-component.adoc[Camel ClickUp]}} to the list.

_Claude Code on behalf of davsclaus_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to