Dhairya-007 opened a new pull request, #29542:
URL: https://github.com/apache/camel/pull/29542
`AbstractWatsonxAiHandler.resolveFileName` gives a streamed document its
name from, in order, the explicit `CamelIBMWatsonxAiFileName` header, the S3
object key, the Azure blob name and finally `CamelFileName`:
```java
// Priority: explicit header > S3 > Azure > Camel file name
fileName = in.getHeader("CamelAwsS3Key", String.class);
...
fileName = in.getHeader("CamelAzureStorageBlobName", String.class);
```
The S3 name is right (`AWS2S3Constants.KEY = "CamelAwsS3Key"`), but the
Azure one is not. `camel-azure-storage-blob` builds its headers from a prefix:
```java
private static final String HEADER_PREFIX = "CamelAzureStorageBlob";
...
public static final String BLOB_NAME = HEADER_PREFIX + "BlobName"; //
"CamelAzureStorageBlobBlobName"
```
and `BlobConsumer` sets `BlobConstants.BLOB_NAME` on every exchange. No
component sets `CamelAzureStorageBlobName`, so the Azure step never matches and
a route like the one in the component's own examples
(`from("azure-storage-blob://mycontainer?prefix=documents/").to("ibm-watsonx-ai:extract?operation=textExtractionUploadAndFetch...")`)
resolves the name from `CamelFileName` if present, or fails with *File name
must be provided via header 'CamelIBMWatsonxAiFileName' when using InputStream
input*.
Fix: read `CamelAzureStorageBlobBlobName`. Both foreign header names are now
package-visible constants on the handler, with a comment naming the constant
they mirror, so the next reader can check them against the source. The module
cannot depend on camel-azure-storage-blob, hence the literal.
Test: `AbstractWatsonxAiHandlerFileNameTest` covers the resolution order
with an anonymous handler subclass: explicit header first, then the S3 key,
then the Azure blob name (this case failed before the fix with the
`IllegalArgumentException`), then `CamelFileName`, and the exception when
nothing names the file.
--
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]