Claus Ibsen created CAMEL-27673:
-----------------------------------
Summary: camel-google-speech-to-text: component options not
exposed, late validation, doc key path
Key: CAMEL-27673
URL: https://issues.apache.org/jira/browse/CAMEL-27673
Project: Camel
Issue Type: Bug
Components: camel-google
Reporter: Claus Ibsen
Fix For: 4.24.0
Found while improving the option descriptions of camel-google-speech-to-text
for CAMEL-23832 (commit
https://github.com/apache/camel/commit/dfb5d274578917536265cf39209ab90d1f9ad6ef).
These are separate problems of the component; the descriptions commit only
documents the current behavior.
h4. 1. The component options are not configurable
{{GoogleCloudSpeechToTextComponent}} has a {{configuration}} field with
{{@Metadata}}, but no setter. The generated
{{GoogleCloudSpeechToTextComponentConfigurer}} therefore knows only
{{lazyStartProducer}} and {{autowiredEnabled}}, and the catalog lists no
component options. A user cannot set {{serviceAccountKey}}, {{encoding}},
{{languageCode}}, {{client}} and the others once on the component with
properties (for example
{{camel.component.google-speech-to-text.serviceAccountKey}}); only Java code
can, through {{getConfiguration()}}. Otherwise they must be repeated on every
endpoint.
Add {{setConfiguration()}} and expose the configuration options as component
options, as {{GoogleCloudStorageComponent}} does.
h4. 2. A wrong operation or encoding fails only at the first message
{{GoogleCloudSpeechToTextProducer.determineOperation()}} calls
{{GoogleCloudSpeechToTextOperations.valueOf()}} and {{performRecognize()}}
calls {{RecognitionConfig.AudioEncoding.valueOf()}} for each message. A typo
such as {{google-speech-to-text:recognise}} or {{encoding=LINEAR}} starts fine
and fails every exchange with an {{IllegalArgumentException}}. The metadata has
no {{enums}} for the {{operation}} path and the {{encoding}} option, so tooling
cannot validate them either.
Add {{enums}} to both options (or use the enum types), and validate the values
when the endpoint is created or started.
h4. 3. Doc page examples use a key path that is read from the classpath
The examples of {{google-speech-to-text-component.adoc}} use
{{serviceAccountKey=/home/user/Downloads/my-key.json}}.
{{GoogleCredentialsHelper.loadServiceAccountCredentials()}} resolves the value
with {{ResourceHelper.resolveMandatoryResourceAsInputStream()}}, which uses the
classpath when there is no prefix, so the file is not found.
Use {{file:/home/user/Downloads/my-key.json}} in the examples.
_Claude Code on behalf of davsclaus_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)