langchain - ✅(Solved) Fix Inconsistent multimodal image format: JS camelCase vs Python snake_case [3 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
langchain-ai/langchain#35548Fetched 2026-04-08 00:25:41
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×3labeled ×1

LangGraph JS SDK generates mimeType (camelCase), Python expects mime_type (snake_case).

Root Cause

LangGraph JS SDK generates mimeType (camelCase), Python expects mime_type (snake_case).

Fix Action

Fixed

PR fix notes

PR #35549: fix: accept both camelCase and snake_case in multimodal image format

Description (problem / solution / changelog)

Summary

Fixes inconsistent multimodal image format between JS and Python SDKs. LangGraph JS SDK generates camelCase keys (mimeType, sourceType), but Python expected snake_case (mime_type, source_type), causing 400 BadRequestError when using Agent Chat UI (JS) → Python agent.

Changes

  • Normalize mimeTypemime_type in _convert_legacy_v0_content_block_to_v1
  • Normalize sourceTypesource_type for consistency
  • Add comprehensive tests for camelCase to snake_case conversion
  • Support both formats for backward compatibility

Testing

Added unit tests covering:

  • Image blocks with camelCase keys
  • Audio blocks with camelCase keys
  • File blocks with camelCase keys
  • Existing snake_case blocks (unchanged behavior)

Fixes #35548

Changed files

  • libs/core/langchain_core/messages/block_translators/langchain_v0.py (modified, +7/-0)
  • libs/core/tests/unit_tests/messages/block_translators/test_langchain_v0.py (modified, +57/-0)

PR #35552: fix: Support camelCase mimeType from JS SDK in multimodal content blocks

Description (problem / solution / changelog)

Problem

LangGraph JS SDK sends camelCase keys (mimeType, sourceType) but Python SDK expected snake_case (mime_type, source_type). This caused 400 BadRequestError when using Agent Chat UI (JS) → Python agent.

Solution

  • Added _get_mime_type() helper to check both camelCase and snake_case
  • Updated all 9 locations in _convert_legacy_v0_content_block_to_v1()
  • Updated all known_keys sets to include mimeType

Changes

  • libs/core/langchain_core/messages/block_translators/langchain_v0.py: Added helper + updated all block conversions
  • libs/core/tests/unit_tests/messages/block_translators/test_langchain_v0.py: Added 16 comprehensive tests

Testing

  • All 45 tests pass in block_translators module
  • Tested image, audio, file blocks with both camelCase and snake_case
  • Verified backward compatibility

Fixes #35548

cc @eyurtsev (maintainer who triaged original issue)

Changed files

  • libs/core/langchain_core/messages/block_translators/langchain_v0.py (modified, +16/-1)
  • libs/core/tests/unit_tests/messages/block_translators/test_langchain_v0.py (modified, +68/-0)

PR #35554: fix: Support camelCase mimeType in multimodal content blocks

Description (problem / solution / changelog)

Summary

LangGraph JS SDK sends camelCase keys (mimeType) while the Python SDK expected snake_case. This fix ensures cross-SDK compatibility by normalizing keys during v0 block conversion.

Changes

  • Added _get_mime_type helper in langchain_v0.py
  • Updated all block translation paths
  • Added 16 unit tests for camelCase normalization

Fixes #35548

— FORGE

Changed files

  • libs/core/langchain_core/messages/block_translators/langchain_v0.py (modified, +16/-1)
  • libs/core/tests/unit_tests/messages/block_translators/test_langchain_v0.py (modified, +68/-0)
  • libs/core/uv.lock (modified, +1/-1)
RAW_BUFFERClick to expand / collapse

Title: Inconsistent multimodal image format: JS camelCase vs Python snake_case

Description

LangGraph JS SDK generates mimeType (camelCase), Python expects mime_type (snake_case).

Reproduction

  1. Agent Chat UI (JS) → Python agent
  2. Image upload → 400 BadRequestError: "Invalid value: image"

Messages from Agent Chat UI:

{
  "type": "image",
  "mimeType": "image/jpeg",  // ❌ Python expects mime_type
  "data": "...",
  "sourceType": "base64"     // ❌ Python expects source_type,witch is missing
}

## Expected
Unified snake_case across Python/JS SDKs.

extent analysis

Fix Plan

Unified Snake Case Across SDKs

To resolve the issue, we need to unify the naming convention across the Python and JS SDKs. We will change the camelCase to snake_case in the JS SDK.

Step 1: Update JS SDK

Update the mimeType and sourceType fields to use snake_case in the JS SDK.

// Before
{
  "type": "image",
  "mimeType": "image/jpeg",
  "data": "...",
  "sourceType": "base64"
}

// After
{
  "type": "image",
  "mime_type": "image/jpeg",
  "data": "...",
  "source_type": "base64"
}

Step 2: Update Python SDK

Update the Python SDK to expect snake_case for mime_type and source_type.

# Before
def process_image(image_data):
    mime_type = image_data['mimeType']
    source_type = image_data['sourceType']

# After
def process_image(image_data):
    mime_type = image_data['mime_type']
    source_type = image_data['source_type']

Step 3: Update Agent Chat UI

Update the Agent Chat UI to send the image data with snake_case fields.

// Before
const imageData = {
  "type": "image",
  "mimeType": "image/jpeg",
  "data": "...",
  "sourceType": "base64"
};

// After
const imageData = {
  "type": "image",
  "mime_type": "image/jpeg",
  "data": "...",
  "source_type": "base64"
};

Verification

  1. Send an image from the Agent Chat UI to the Python agent.
  2. Verify that the image is processed correctly without any errors.
  3. Check the logs to ensure that the mime_type and source_type

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

langchain - ✅(Solved) Fix Inconsistent multimodal image format: JS camelCase vs Python snake_case [3 pull requests, 1 participants]