[
https://issues.apache.org/jira/browse/CAMEL-23960?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Federico Mariani updated CAMEL-23960:
-------------------------------------
Attachment: OpenAIOutputClassUnresolvableTest.java
> camel-openai: unresolvable outputClass is silently ignored instead of failing
> -----------------------------------------------------------------------------
>
> Key: CAMEL-23960
> URL: https://issues.apache.org/jira/browse/CAMEL-23960
> Project: Camel
> Issue Type: Bug
> Components: camel-openai
> Affects Versions: 4.21.0
> Reporter: Federico Mariani
> Priority: Minor
> Labels: ai
> Attachments: OpenAIOutputClassUnresolvableTest.java
>
>
> In {{OpenAIProducer.processInternal}}:
> {code:java}
> if (ObjectHelper.isNotEmpty(outputClass)) {
> Class<?> responseClass =
> getEndpoint().getCamelContext().getClassResolver().resolveClass(outputClass);
> if (responseClass != null) {
> paramsBuilder.responseFormat(responseClass);
> }
> }
> {code}
> If the class cannot be resolved (typo in the FQCN, missing dependency), the
> structured-output configuration is silently skipped: the request is sent
> without {{response_format}} and the user receives unstructured output with no
> error or warning. An unresolvable {{outputClass}} is always a configuration
> error and should fail fast — exactly like the invalid-{{jsonSchema}} case a
> few lines below, which throws {{IllegalArgumentException}}.
> Reproducer attached ({{OpenAIOutputClassUnresolvableTest}}); it asserts
> fail-fast behavior and fails on current main.
> h3. Suggested fix
> Throw {{IllegalArgumentException("outputClass '...' cannot be resolved")}}
> when {{resolveClass}} returns null. Ideally resolve once in {{doStart}} (the
> option is endpoint-level) so misconfiguration fails at route startup; a
> per-header {{CamelOpenAIOutputClass}} value should fail per exchange. Note
> the header metadata declares {{javaType = "Class"}} while the producer
> resolves it as a String FQCN — the metadata should be corrected to String at
> the same time.
> _This issue was drafted by Claude Code on behalf of Federico Mariani_
--
This message was sent by Atlassian Jira
(v8.20.10#820010)