Claus Ibsen created CAMEL-27631:
-----------------------------------

             Summary: camel-huaweicloud-imagerecognition: setImageClient needs 
keys, required flags, enums, metadata
                 Key: CAMEL-27631
                 URL: https://issues.apache.org/jira/browse/CAMEL-27631
             Project: Camel
          Issue Type: Bug
            Reporter: Claus Ibsen
             Fix For: 4.24.0


Found while improving the option descriptions of 
camel-huaweicloud-imagerecognition for CAMEL-23832 (PR 
https://github.com/apache/camel/pull/30973).
These are separate problems of the component; the descriptions PR only 
documents the current behavior.

h4. 1. A client set with setImageClient still needs access key, secret key and 
project ID
{{ImageRecognitionProducer.process()}} calls {{initializeConfigurations()}} for 
every message before it looks at the client. That method calls 
{{getAccessKey()}}, {{getSecretKey()}} and {{getProjectId()}}, which throw an 
{{IllegalArgumentException}} when the value is missing. So a route that sets an 
{{ImageClient}} on the endpoint with 
{{ImageRecognitionEndpoint.setImageClient()}} and no credentials fails on every 
message with "authentication parameter 'access key (AK)' not found", although 
{{initializeSdkClient()}} would use the given client.
Proposed change: build the credential part of the configuration only when the 
producer creates the client itself, and build it once (in {{doStart()}} or on 
the first message) instead of for every message.

h4. 2. Exchange properties are not in the component metadata, and the doc gives 
a wrong type
The producer reads the exchange properties {{CamelHwCloudImageContent}}, 
{{CamelHwCloudImageUrl}}, {{CamelHwCloudImageTagLanguage}}, 
{{CamelHwCloudImageTagLimit}} and {{CamelHwCloudImageThreshold}} 
({{ImageRecognitionProperties}}, read in 
{{ImageRecognitionProducer.updateClientConfigurations()}}). They have no 
{{@Metadata}}, so they are not in the component JSON, the catalog or the 
Endpoint DSL. They appear only in a hand-written table of 
{{hwcloud-imagerecognition-component.adoc}}, which gives 
{{CamelHwCloudImageThreshold}} the type {{Integer}}, while the producer reads 
it with {{exchange.getProperty(THRESHOLD, Float.class)}}.
Proposed change: fix the type in the doc table to {{Float}}, and consider 
documenting the properties in the metadata (or supporting headers of the same 
name, as other components do).

h4. 3. accessKey, secretKey and region are marked as required
{{ImageRecognitionEndpoint}} marks {{accessKey}} and {{secretKey}} with 
{{@Metadata(required = true)}}, but {{ImageRecognitionProducer.getAccessKey()}} 
and {{getSecretKey()}} fall back to the {{serviceKeys}} option when they are 
not set. {{region}} is also marked as required, but 
{{ImageRecognitionProducer.getEndpoint()}} does not use it when {{endpoint}} is 
set. Tools that validate the URI against the catalog report these options as 
missing for a valid configuration.
Proposed change: set {{required = false}} on {{accessKey}}, {{secretKey}} and 
{{region}}.

h4. 4. operation and tagLanguage have no enums
The producer accepts only {{celebrityRecognition}} and {{tagRecognition}} for 
{{operation}} ({{ImageRecognitionProducer.process()}}) and only {{zh}} and 
{{en}} for {{tagLanguage}} ({{updateClientConfigurations()}}), but the 
{{@UriPath}} and {{@UriParam}} have no {{enums}}, so the catalog and the 
tooling cannot offer or check the values.
Proposed change: add {{enums = "celebrityRecognition,tagRecognition"}} and 
{{enums = "zh,en"}}.

h4. 5. Category MESSAGING
The {{@UriEndpoint}} of {{ImageRecognitionEndpoint}} has {{category = { 
Category.CLOUD, Category.MESSAGING }}}. Image Recognition is not a messaging 
service.
Proposed change: remove {{Category.MESSAGING}} (and consider {{Category.AI}}).

_Claude Code on behalf of davsclaus_



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

Reply via email to