atiaomar1978-hub opened a new pull request, #25893: URL: https://github.com/apache/camel/pull/25893
## Summary Implements [CAMEL-24551](https://issues.apache.org/jira/browse/CAMEL-24551): when an AI producer call fails, Camel sets structured error metadata on the Exchange **before** the exception propagates, so routes can react in `onException` without introspecting SDK-specific exception types. **New exchange properties:** - `CamelAiErrorCategory` — `RATE_LIMIT`, `SERVER_ERROR`, `VALIDATION`, `AUTH`, or `UNKNOWN` - `CamelAiRetryAfterMillis` — retry delay in ms when the provider exposes `Retry-After` / `Retry-After-Ms` (**OpenAI only**) ## Design Per Karol Krawczyk's JIRA analysis: - Classification runs via `GenAiErrorSupport.apply()` in each producer catch block — **independent** of GenAI observability (works when observability is disabled or `camel-ai-observability` is absent) - Shared logic lives in `camel-ai-observability-api` using class-name/hierarchy matching and reflection (no compile dependency on OpenAI SDK; no langchain4j on runtime classpath for Spring AI consumers) - Specific SDK causes are preferred over Spring AI wrapper exceptions in the cause chain - LangChain4j/Spring AI producers populate category only; OpenAI also parses retry headers ## Producers updated - `camel-openai` (sync chat, streaming setup, streaming iterator, and top-level `process()` failure path) - `camel-langchain4j-chat` - `camel-langchain4j-agent` - `camel-langchain4j-embeddings` - `camel-spring-ai-chat` ## Tests - `GenAiErrorSupportTest` — langchain4j, Spring AI wrappers, HTTP 408, cause-chain specificity - `OpenAIErrorMetadataTest` — OpenAI SDK classification + Retry-After / Retry-After-Ms parsing - `LangChain4jChatErrorMetadataTest` — producer integration with observability disabled - `SpringAiChatErrorMetadataTest` — producer integration with observability disabled Related: CAMEL-24550 (documentation for targeted `onException` handling) _AI-generated PR description on behalf of atiaomar1978-hub_ -- 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]
