← Back to Pull requests

[api][integrations][java][python] Raise a clear error for an output schema that cannot be rendered #1046

Closed
unknown closed this pull request without merging on Aug 31, 2026 07:18 UTC
View on GitHub
unknown unknown commented on Aug 24, 2026 02:52 UTC
Author

Linked issue: #985

Purpose of change

An output schema that cannot be rendered as JSON Schema fails opaquely. Python leaks a raw PydanticInvalidForJsonSchema naming 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. RowTypeInfo stays a fallback and is documented as one on the public chat contract, 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, not ValueError. 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_format conflict is reported before the render |

The Java connections are deliberately untouched. Validating them with Jackson would refuse schemas the providers accept: a @JsonTypeInfo member renders empty under Jackson while the SDK ships a full anyOf union, 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 RowTypeInfo handling, no new dependency, no payload change for a schema that renders, and output_schema still is not threaded from the runtime to a connection in either language.

Tests

ReActAgentTest and test_react_agent.py are the first unit coverage of ReActAgent in either language.

Per site: an unrenderable schema raises with the cause chained, a dict/Map member is accepted and still sent whole, and a normal schema produces the payload it produced before.

Two assertions are load-bearing:

  • The self-referential test asserts the chained cause, not only that something was thrown. Removing the catch clause fails it with a raw StackOverflowError, which is the regression it exists to catch.

  • The Python self-reference test asserts a top-level $ref. A model that merely nests another model has $defs but 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 api 380 passed, openai 104, anthropic 61, zero failures, spotless:check clean. Python: pytest flink_agents --ignore=flink_agents/e2e_tests -m "not integration" 940 passed, 13 skipped. check-license.sh clean. The e2e failures in this worktree are pre-existing, from jars never built here.

    tools/lint.sh could 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.java is 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-included
  • Was this patch authored or co-authored using generative AI tooling?

  • Yes
  • Generated-by: Claude Code v2.1.53 (claude-opus-5[1m])

    Diff: 588 lines (+441 / -147) across 7 files Reviewer: weiqingy Review duration: 10346m
    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
    0.50
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 50.0% (MEDIUM) · Higher = larger blast radius
    50.0%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 21.6% · Safe to merge
    21.6%