[api][integrations][java][python] Raise a clear error for an output schema that cannot be rendered #1046
All Vouch review confidence checks passed
Residual risk 0.22 = Change Risk (0.50) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.50 · 588 lines diff across 7 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.382
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #1046"
general
weight: 0.35
weiqingy
Linked issue: #985
Purpose of change
An output schema that cannot be rendered as JSON Schema fails opaquely. Python leaks a raw
PydanticInvalidForJsonSchemanaming a pydantic-internal type, never the caller's model. Java throws past a catch clause too narrow to see it.Per the decision on the issue, such a schema is now refused with a clear, cause-chained error naming the schema.
RowTypeInfostays a fallback and is documented as one on the publicchatcontract, which previously said nothing about how a connection treats each kind of schema.A schema that renders but declares no fields is returned as rendered, in both languages. Whether such a document is usable belongs to whatever consumes it.
Observable changes:
| Where | Change |
|---|---|
| Python, all 4 sites | unrenderable schema raises
TypeError, cause chained || Java ReAct | catch widened to what Jackson actually throws; rethrown as
IllegalArgumentException, cause chained || Java ReAct | a self-referential POJO overflows the stack inside Jackson. That is an
Error, so it escaped the catch entirely. Now reported as a schema that refers back to itself || Java ReAct | an unsupported output schema type now names the type received, matching the Python message |
| Anthropic (py) | a model pydantic renders but Anthropic refuses now raises
TypeError, notValueError. Only site where the new type is not a subtype of the old || Anthropic (py) | no render at all when the caller supplies
output_config, so a discarded schema can no longer fail the call || Azure (py) | the caller
response_formatconflict is reported before the render |The Java connections are deliberately untouched. Validating them with Jackson would refuse schemas the providers accept: a
@JsonTypeInfomember renders empty under Jackson while the SDK ships a fullanyOfunion, and Jackson throws on field-less, colliding-property and self-referential POJOs that the SDKs send today. Validating the SDK's own schema is no better, since it renders a map member and an unrenderable member identically. Probed with 15 hostile classes, the SDKs never failed to render, so there is no failure there to report.That leaves one asymmetry, imposed by the libraries rather than chosen: pydantic raises where the Java SDKs do not.
Not in scope: no change to
RowTypeInfohandling, no new dependency, no payload change for a schema that renders, andoutput_schemastill is not threaded from the runtime to a connection in either language.Tests
ReActAgentTestandtest_react_agent.pyare the first unit coverage ofReActAgentin either language.Per site: an unrenderable schema raises with the cause chained, a
dict/Mapmember is accepted and still sent whole, and a normal schema produces the payload it produced before.Two assertions are load-bearing:
StackOverflowError, which is the regression it exists to catch.$ref. A model that merely nests another model has$defsbut no top-level$ref, so the weaker guards pass on a non-cyclic model and would miss a regression.Both languages pin that an unsupported output schema type names the type it received, so neither message can silently stop reporting it.
Verified. Java:
mvn clean test -pl api380 passed, openai 104, anthropic 61, zero failures,spotless:checkclean. Python:pytest flink_agents --ignore=flink_agents/e2e_tests -m "not integration"940 passed, 13 skipped.check-license.shclean. The e2e failures in this worktree are pre-existing, from jars never built here.tools/lint.shcould not run locally (its Python step needs an editable install this pip is too old to perform).ruff check, which is what that step runs, is clean on every changed file.API
Yes. One helper in
flink_agents.api.agents.types:render_output_schema, used by the three chat model connections and by the ReAct prompt path. It renders through a callable the caller supplies, and reports a render failure clearly.No Java helper is added.
OutputSchema.javais unchanged.No existing signature changes. Exception types change as listed above, and two error messages change wording: the Java unsupported-type message now names the type, and the Python translation failure no longer describes its caller as a chat model, since the prompt path is also a caller.
Documentation
doc-includedWas this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code v2.1.53 (claude-opus-5[1m])