Back

langchain #35030

fix(openai): openai sdk validation error not surfaced in `with_structured_output`

by LouisAuneau · Feb 06, 2026 at 19:28 UTC · scan-c210b0cc20dfb857

Low Risk (20%)

Get this automatically on every PR

Install the Axiomo GitHub App to get Signals as check runs and PR comments on every pull request.

Install App

Risk Assessment

Risk level: Low (20%)

Risk Drivers

  • api_surface_change: API surface changed in 2 file(s)

Intent

3/3 criteria met

Surface OpenAI SDK validation errors in `with_structured_output` using parsing_error.

Non-Goals

  • - Change the OpenAI SDK validation logic
  • - Modify the LangChain output parsers
  • - Address redundant validation entirely

Acceptance Criteria

  • โœ“
    Validation errors from OpenAI SDK are surfaced.

    BaseChatOpenAI wraps LLM call to capture ValidationError in `parsing_error`.

  • โœ“
    Modified chain allows retry mechanisms.

    `RunnableBranch` checks for parsing errors before proceeding.

  • โœ“
    Only validation-related changes are made to method behavior.

    Only `_get_raw_structured_output_chain` logic is changed.

Confidence: 95.0% Source: pr description AI: openai

Contributors

LouisAuneau PR Author ? Low Trust
Account Age: 3798 days
Prior PRs: 3
Merged: 2

Has 2 merged PRs to this repo. unfamiliar with 2 files.

Evidence

Evidence Completeness: 70.0%
ci_passing Passing
tests_passing Unavailable
build_successful Passing
lint_passing Passing
Missing: security_scan_clean, coverage_maintained

Supply Chain

None Risk
Modifies dependencies
Modifies lockfile
Modifies CI config
Modifies build scripts

Focus Files

Review 1 high-priority file(s)

libs/partners/openai/langchain_openai/chat_models/base.py +86

86 lines changed; Source code

high
libs/partners/openai/tests/unit_tests/chat_models/test_base.py +68

68 lines changed; Source code

medium

Triage

24

minutes to review

medium

effort level

none

staleness risk

Standard review process

Recommendation

COMMENT 67.0% readiness

Some concerns to address before approval

Next Steps

Question

Why is security_scan_clean missing? Consider adding this check.

Question

Why is coverage_maintained missing? Consider adding this check.