saravanakumar1987 opened a new pull request, #30004:
URL: https://github.com/apache/camel/pull/30004

   # Description
   
   Part of [CAMEL-23832](https://issues.apache.org/jira/browse/CAMEL-23832). 
This pull request covers `camel-alibaba-fc` (scheme `alibaba-fc`). It does not 
complete the ticket, so please keep the ticket open.
   
   This is the second of the eight Alibaba components, after 
`camel-alibaba-ots` (#29991). The texts of `operation`, `accessKey`, 
`secretKey` and `serviceKeys` are the texts merged there, with the fc names.
   
   Only description texts change: 10 endpoint options and 5 headers. No option 
or header is added, removed or renamed, and no default value, label, type or 
enum value changes. The component description stays as it is.
   
   The new texts are in the `description` attribute of the annotations 
(`@UriPath` and `@UriParam` on the endpoint options, `@Metadata` on the header 
constants). The old texts were already in that attribute and no setter had 
Javadoc, so no Javadoc is removed.
   
   The names were checked against the Alibaba Cloud FC-Open SDK for Java 2.1.0 
sources (`com.aliyun:fc_open20210406`), the version set by 
`aliyun-fc-open-version` in `parent/pom.xml`. Its client extends the client of 
`com.aliyun:tea-openapi` 0.3.20 (`tea-openapi-version`) and runs on 
`com.aliyun:tea` 1.4.3 (`tea-version`), whose sources were read too. The SDK 
calls the Function Compute 2.0 API (version 2021-04-06), so the texts use its 
terms service, function, version and alias.
   
   | Text | Problem in the current text | Checked against |
   |---|---|---|
   | `operation` (endpoint path option) | It does not say that the 
CamelAlibabaFcOperation header, and after it an exchange property of the same 
name, replace the option. | `FCComponent.createEndpoint` (the path of the 
endpoint URI), `FCProducer.process`, `FCUtils.createClientConfigurations`, 
camel-alibaba-common `OpenApiClientSupport.resolveString` (the header, else the 
exchange property of the same name, else the option), `FCProperties` (the name 
CamelAlibabaFcOperation); the ots text word for word, with the fc header name; 
no test sets the header or the exchange property, so this rests on reading the 
code |
   | `region` (endpoint option) | It does not say that the value is a region 
ID, that it only builds the endpoint when the endpoint option is not set, nor 
that it is not used when fcClient is set or autowired. | `FCUtils.createClient` 
and `createTeaConfig` (region or endpoint is required, and the region goes into 
the SDK configuration only when it is not empty; no other Camel code reads the 
option), `FCEndpoint.initClient`, `DefaultEndpoint.doInit` with the generated 
`FCEndpointConfigurer` (a single `Client` in the registry is autowired into 
fcClient); FC-Open SDK `Client` (a set endpoint is used as it is, else the 
entry of the region in its endpoint map, else endpoint-util builds one); 
tea-openapi `Client` (the region ID is read only by `execute`, which the fc 
operations do not use, because Camel sets no signature version or algorithm); 
the region on the doc page and in `testconfiguration.properties` (cn-hangzhou); 
the Function Compute endpoint pages (Region ID) |
   | `endpoint` (endpoint option) | It calls the value a URL, although the SDK 
takes a host name and every request fails when the value has http:// or 
https://, and "Carries higher precedence than region based client 
initialization" does not say what happens. | `FCUtils.createClient` and 
`createTeaConfig` (one of region and endpoint is required, Camel checks nothing 
else); FC-Open SDK `Client.getEndpoint` (a set endpoint is used as it is); 
tea-openapi `Client` (the endpoint is the host of each request, and the 
protocol is the HTTPS of the operation, because Camel sets no protocol); tea 
`Tea` (the URL is the protocol, ://, the host and the path); a run of 
getFunction with the endpoint https://127.0.0.1, on a classpath without the 
NoSuchFieldError of CAMEL-26972, which failed with a `TeaUnretryableException` 
because the host it looked up was https; the Function Compute endpoint pages 
(host names without https://); no test reads the option |
   | `accessKey` (endpoint option) | It does not use the Alibaba Cloud term 
AccessKey ID, and it does not say how the option relates to serviceKeys and 
fcClient. | `FCUtils.createTeaConfig`, camel-alibaba-common 
`OpenApiClientSupport.resolveAccessKey` (the option, else the accessKey of 
serviceKeys, else an IllegalArgumentException), `FCEndpoint.initClient`, 
`DefaultEndpoint.doInit`; tea-openapi `Client` (an access_key credential from 
accessKeyId and accessKeySecret, and the ACS3-HMAC-SHA256 Authorization header, 
which carries the AccessKey ID and is signed with the AccessKey secret); the 
RAM documentation of the AccessKey pair; the ots text word for word, with 
Function Compute and fcClient |
   | `secretKey` (endpoint option) | It does not use the Alibaba Cloud term 
AccessKey secret, and it does not say how the option relates to serviceKeys and 
fcClient. | `FCUtils.createTeaConfig`, `OpenApiClientSupport.resolveSecretKey` 
(as `accessKey`), `FCEndpoint.initClient`, `DefaultEndpoint.doInit`; 
tea-openapi `Client` (the AccessKey secret signs the request); the RAM 
documentation of the AccessKey pair; the ots text word for word, with Function 
Compute and fcClient |
   | `serviceKeys` (endpoint option) | It does not say what the object holds, 
nor when its values are used. | camel-alibaba-common `ServiceKeys` (the 
properties accessKey and secretKey), `OpenApiClientSupport.resolveAccessKey` 
and `resolveSecretKey` (each key falls back to serviceKeys on its own), 
`FCUtils.createClient`, `FCEndpoint.initClient`, `DefaultEndpoint.doInit`; the 
ots text word for word, with fcClient |
   | `serviceName` (endpoint option) | It does not say that a header and an 
exchange property replace the option, nor that one of them is required. | 
`FCUtils.createClientConfigurations` and `OpenApiClientSupport.resolveString` 
(as `operation`), `FCProducer.validateServiceAndFunction` (an empty service or 
function name fails, for both operations); FC-Open SDK `Client` (both 
operations send to a path below 
/2021-04-06/services/{serviceName}/functions/{functionName}); the Function 
Compute 2.0 API reference (a service contains functions); `InvokeFunctionTest` 
and `InvokeFunctionPayloadTest` set the option, and no test sets the header or 
the exchange property |
   | `functionName` (endpoint option) | It does not say that a header and an 
exchange property replace the option, nor that one of them is required. | as 
`serviceName`; the 2021-04-06 API reference and FC-Open SDK 
`GetFunctionResponseBody` (The name of the function) |
   | `qualifier` (endpoint option) | It calls the value a version or alias of 
the function, but in the Function Compute 2.0 API that the component calls it 
is a version or alias of the service, and it does not say that a header and an 
exchange property replace the option. | `FCUtils.createClientConfigurations` 
and `OpenApiClientSupport.resolveString` (as `operation`), `FCProducer` (both 
operations put the value on the request only when it is not empty); FC-Open SDK 
`Client` (the query parameter qualifier, only when it is set), 
`InvokeFunctionRequest` (The version ID or alias of the service) and 
`GetFunctionRequest` (The version or alias of the service); the 2021-04-06 API 
reference; no test sets the qualifier |
   | `fcClient` (endpoint option) | It does not say what the option replaces, 
nor who creates the client and when. | `FCEndpoint` (`initClient`, 
`setFcClient` and its flag, `doStop`, which drops the reference to a client 
that the Camel endpoint created and closes nothing), `FCProducer.process` (it 
calls `initClient` while its own reference is null, so for the first message), 
the generated `FCEndpointConfigurer` (`getAutowiredNames`), 
`DefaultEndpoint.doInit` (autowiring); FC-Open SDK `Client`, which extends the 
tea-openapi `Client` (neither has a method to close or shut down the client, so 
the sentences of the otsClient text about shutting down are left out); 
`InvokeFunctionTest` and `InvokeFunctionPayloadTest` set fcClient with a mock, 
and no test covers creating the client, autowiring or `doStop` |
   | `CamelAlibabaFcServiceName` (header) | It says override without saying 
what is overridden. | as `serviceName`: `FCUtils.createClientConfigurations`, 
`OpenApiClientSupport.resolveString`; no test sets the header |
   | `CamelAlibabaFcFunctionName` (header) | It says override without saying 
what is overridden. | as `functionName`; no test sets the header |
   | `CamelAlibabaFcQualifier` (header) | It says override without saying what 
is overridden. | as `qualifier`; no test sets the header |
   | `CamelAlibabaFcRequestId` (header) | It does not say who sets the header, 
nor that only invokeFunction sets it. | `FCProducer` (invokeFunction copies the 
response header x-fc-request-id when it is not empty, and getFunction does not 
set the header); tea `TeaResponse` with OkHttp (the header names are 
lower-cased); tea-openapi `Client` (for a status code from 400 to 599 the SDK 
throws unless returnErrorResponse is set, which Camel does not do, so the 
exchange fails); the Function Compute documentation (the response header 
X-Fc-Request-Id, and HTTP status 200 with X-Fc-Error-Type when the function 
fails, which is why the text says "unless the exchange fails" and not "when the 
operation succeeds"); no test checks the header |
   | `CamelAlibabaFcStatusCode` (header) | It says the header comes from the 
invoke response, but getFunction sets it too, and it does not say when the 
producer sets it. | `FCProducer` (both operations set the status code of the 
response when it is not null); FC-Open SDK `InvokeFunctionResponse` and 
`GetFunctionResponse` (statusCode), which tea `TeaResponse` takes from the HTTP 
response; tea-openapi `Client` (as `CamelAlibabaFcRequestId`); 
`InvokeFunctionTest` checks the statusCode entry of the body Map, not the 
header |
   
   ## Found in the review, not changed here
   
   - With the versions that camel-parent manages, every request of this 
component fails with a NoSuchFieldError. This is reported as CAMEL-26972.
   - `region` has `@Metadata(required = true)`, but the code needs `region` or 
`endpoint`, and neither when `fcClient` is set or autowired. Catalog validation 
reports `region` as missing for a URI that sets only `endpoint` or only 
`fcClient`, as a run against the catalog of this branch shows. Not verified: no 
route without `region` was run, because every test sets it, so the runtime side 
rests on reading the code.
   - `FCHeaders` has no constant for `CamelAlibabaFcOperation`, which the 
producer reads like the other input headers. Only `FCProperties` declares it, 
so the header is missing from the header list of the component JSON, the 
endpoint DSL and the doc page, and only the `operation` text names it. Not 
verified: no test sets the header, so that the producer reads it rests on 
reading the code.
   - `FCProperties` has `@Metadata` with texts of its own on its five header 
names, but the build reads only the headers class `FCHeaders` and its 
supertypes, so these texts are not used, and the four that `FCHeaders` also 
declares now differ from its texts. The generated JSON shows this, as it has no 
entry for the `OPERATION` constant of `FCProperties`. Not verified: whether a 
tool outside the Camel build reads these annotations.
   - With `region` alone, the SDK sends the requests to 
`account-id.{region}.fc.aliyuncs.com` for the 21 regions of its endpoint map, 
with the literal text account-id that nothing replaces, and to 
`fc-open.{region}.aliyuncs.com` for the other regions. The Function Compute 
documentation gives the form `{account-ID}.{region-ID}.fc.aliyuncs.com`, with 
the ID of the Alibaba Cloud account, and the examples of the doc page set only 
`region`. Not verified: whether such a request reaches Function Compute, as no 
request was sent to Alibaba Cloud.
   - `FCEndpoint.initClient` and the producer's check of its own client field 
are not synchronized, and the fields are not volatile, so two messages that 
arrive before the first client exists can each create a client, and the Camel 
endpoint keeps the last one. This is the pattern of CAMEL-26971 
(camel-alibaba-ots), but nothing leaks here: the FC client starts no thread and 
opens no connection when it is created, and the SDK shares its OkHttp clients 
in a static map. Not verified by a run: this was found by reading the code and 
the SDK sources.
   - When the function itself fails, Function Compute answers with HTTP status 
200 and the response header X-Fc-Error-Type, as its documentation says. Neither 
the SDK nor the producer checks that header, so the exchange does not fail: the 
body Map holds the error payload, the error type is only in its headers entry, 
and the doc page does not say so. Not verified: no request was sent to Function 
Compute, so this rests on the documentation and on the SDK and Camel code.
   - The producerOut body type text, added by CAMEL-24961, names the 
`CamelAlibabaFcStatusCode` header for invokeFunction only, but getFunction sets 
it too. This pull request changes only option and header texts, so that text 
stays as it is. Not verified: no test calls getFunction, so this rests on 
reading the producer code.
   
   # Target
   
   - [x] I checked that the commit is targeting the correct branch (Camel 4 
uses the `main` branch)
   
   # Tracking
   
   - [x] If this is a large change, bug fix, or code improvement, I checked 
there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for 
the change (usually before you start working on it).
   
   # Apache Camel coding standards and style
   
   - [x] I checked that each commit in the pull request has a meaningful 
subject line and body.
   - [x] I have run `mvn clean install -Dquickly -DskipTests` from the root 
folder and then `mvn install -DskipTests -nsu` in 
`components/camel-alibaba/camel-alibaba-fc`, `catalog/camel-catalog` and 
`dsl/camel-endpointdsl`, and I have committed all auto-generated changes.
   
   # AI-assisted contributions
   
   - [x] If this PR includes AI-generated code, commits have proper 
co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR 
description identifies the AI tool used.
   
   The descriptions and this text were drafted with Claude (Anthropic) and 
checked against the Camel source and the FC-Open SDK for Java 2.1.0 sources.
   
   _Claude Code on behalf of saravanakumar1987_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to