Skip to content

[examples] Quickstart process_chat_response fails fast on malformed JSON#811

Merged
wenjin272 merged 3 commits into
apache:mainfrom
wenjin272:fix-process-response
Jun 8, 2026
Merged

[examples] Quickstart process_chat_response fails fast on malformed JSON#811
wenjin272 merged 3 commits into
apache:mainfrom
wenjin272:fix-process-response

Conversation

@wenjin272

Copy link
Copy Markdown
Contributor

Linked issue: #780

Purpose of change

The quickstart process_chat_response sample caught every exception, logged it, and emitted no OutputEvent. A malformed LLM response then silently produced fewer outputs than inputs with no surface (DLQ event, error event, metric) for downstream operators to detect the missing record — a copy-paste anti-pattern for the recommended learning sample.

  • Replace try/except: log() with fail-fast in the Python quickstart agents (review_analysis_agent, table_review_analysis_agent, product_suggestion_agent); a parse error now propagates and fails the agent. Remove the unused logging imports.
  • Document production alternatives in the comment (raise to fail the input, emit an OutputEvent with an error sentinel, send a custom error event).
  • The Java samples already fail fast; align their comments with the Python ones so the intent is explicit.

Tests

Existing ut & e2e; quickstart examples run unchanged on valid responses and now fail loudly on malformed JSON.

API

no

Documentation

  • doc-needed
  • doc-not-needed
  • doc-included

wenjin272 and others added 3 commits June 8, 2026 17:17
…pache#780)

Replace the log-and-drop except block in the Python quickstart sample with
fail-fast behavior so a malformed LLM response surfaces the dropped input
instead of silently producing no output. Document production alternatives
(error sentinel, error event, raise) and aligns with the Java samples.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Apply the same fail-fast fix to table_review_analysis_agent and
product_suggestion_agent, which shared the log-and-drop pattern.
Remove the now-unused logging imports.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ache#780)

The Java samples already fail fast; add the same explanatory comment as the
Python samples so the choice and production alternatives are documented in
ReviewAnalysisAgent, TableReviewAnalysisAgent and ProductSuggestionAgent.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added doc-included Your PR already contains the necessary documentation updates. fixVersion/0.3.0 The feature or bug should be implemented/fixed in the 0.3.0 version. priority/major Default priority of the PR or issue. labels Jun 8, 2026
@wenjin272 wenjin272 merged commit c0f532d into apache:main Jun 8, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc-included Your PR already contains the necessary documentation updates. fixVersion/0.3.0 The feature or bug should be implemented/fixed in the 0.3.0 version. priority/major Default priority of the PR or issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant