Skip to content

Conversation

@jordan-homan
Copy link
Contributor

@jordan-homan jordan-homan commented Oct 1, 2024

Notes

This PR fixes the input for extractImageBlockType to be sent as an array instead of a comma-delimited string so that the input settings are respected server side.

Testing

Manually inspected server-side after change that the correct input is sent properly.

Updated integration test.

@jordan-homan jordan-homan marked this pull request as ready for review October 1, 2024 20:00
Copy link
Collaborator

@awalker4 awalker4 left a comment

Choose a reason for hiding this comment

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

LGTM! Great catch. If someone adds a new list param to the API, will it have the same issue and is there a generic way to handle it?

@jordan-homan jordan-homan enabled auto-merge (squash) October 3, 2024 13:33
@jordan-homan
Copy link
Contributor Author

LGTM! Great catch. If someone adds a new list param to the API, will it have the same issue and is there a generic way to handle it?

Thought about this - I don't think it would be safe to assume say, searching over the form object and if it contains ",", that we could assume it needs to be converted to an actual list. I think we have to take it case by case and explicitly clean up the input unfortunately.

@jordan-homan jordan-homan merged commit 396f1e4 into main Oct 3, 2024
2 checks passed
@jordan-homan jordan-homan deleted the fix_extract_image_block_type branch October 3, 2024 13:48
awalker4 added a commit that referenced this pull request May 29, 2025
Fixes #135 

The SDK sends the wrong formdata when the user adds an array param. For
instance, the following call:
```
client.general.partition({
    partitionParameters: {
        files: {
            content: data,
            fileName: filename
        },
        extractImageBlockTypes: ["Image", "Table"],
    }
})
```

Sends the list as one comma separated FormData value:
`extract_image_block_types: "Image,Table"'.

The server will ignore this unless it's sent with multiple keys like so:
`extract_image_block_types[]: "Image", extract_image_block_types[]:
"Table"`

We addressed this before in #122 by adjusting the request body before
sending it, but this code path is for pdf splitting. A better solution
is to add a new hook that will clean up the form data for every request.
Then we can remove the modification in the splitting code.
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.

3 participants