Skip to content

fix(split): serialize split_class as a JSON string in multipart form data#114

Open
dex0shubham wants to merge 2 commits into
landing-ai:mainfrom
dex0shubham:fix/split-class-json
Open

fix(split): serialize split_class as a JSON string in multipart form data#114
dex0shubham wants to merge 2 commits into
landing-ai:mainfrom
dex0shubham:fix/split-class-json

Conversation

@dex0shubham

Copy link
Copy Markdown

Fixes #76

Problem

client.split() (and the async variant) fails with a 422 when following the documented example. The split_class list of dicts was passed straight into the multipart body, which the HTTP layer flattens into split_class[0][name]-style fields — but the API expects a single JSON-string form field, so the server responds with 'split_class': Field required.

Fix

Serialize split_class with json.dumps(list(split_class)) before building the multipart body, in both the sync and async split() methods. This is the fix suggested by @cmaloney111 in the issue, and matches the existing pattern used for options in resources/v2/parse.py. The public method signature is unchanged — callers still pass a list of dicts.

Tests

Added tests/test_split_params.py, which asserts the request body carries split_class as one JSON string (fails on the previous code, where it was a raw list). Full test suite passes locally apart from pre-existing environment-specific failures (Windows chmod semantics, httpx proxy mounts) that also fail on a clean checkout.

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings July 15, 2026 12:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes multipart serialization of split_class for split requests.

Changes:

  • JSON-serializes split_class in sync and async clients.
  • Adds regression tests for request-body serialization.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/landingai_ade/_client.py Updates sync and async split request serialization.
tests/test_split_params.py Tests JSON-string request bodies.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/landingai_ade/_client.py Outdated
"split_class": split_class,
# The API expects split_class as a single JSON string form field,
# not flattened multipart fields (https://github.com/landing-ai/ade-python/issues/76).
"split_class": json.dumps(list(split_class)),
Comment thread src/landingai_ade/_client.py Outdated
"split_class": split_class,
# The API expects split_class as a single JSON string form field,
# not flattened multipart fields (https://github.com/landing-ai/ade-python/issues/76).
"split_class": json.dumps(list(split_class)),
Copilot AI review requested due to automatic review settings July 16, 2026 13:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

client.split() fails in v1.6.0

2 participants