fix(split): serialize split_class as a JSON string in multipart form data#114
Open
dex0shubham wants to merge 2 commits into
Open
fix(split): serialize split_class as a JSON string in multipart form data#114dex0shubham wants to merge 2 commits into
dex0shubham wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes multipart serialization of split_class for split requests.
Changes:
- JSON-serializes
split_classin 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.
| "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)), |
| "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)), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #76
Problem
client.split()(and the async variant) fails with a 422 when following the documented example. Thesplit_classlist of dicts was passed straight into the multipart body, which the HTTP layer flattens intosplit_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_classwithjson.dumps(list(split_class))before building the multipart body, in both the sync and asyncsplit()methods. This is the fix suggested by @cmaloney111 in the issue, and matches the existing pattern used foroptionsinresources/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 carriessplit_classas 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