fix: --multipart silently drops := / :=@ JSON fields - #1957
Closed
harsh-thakkar7 wants to merge 1 commit into
Closed
harsh-thakkar7 wants to merge 1 commit into
harsh-thakkar7 wants to merge 1 commit into
Conversation
SEPARATORS_GROUP_MULTIPART is missing SEPARATOR_DATA_RAW_JSON (:=) and SEPARATOR_DATA_EMBED_RAW_JSON_FILE (:=@), so ProcessMultiItemArgs routed those items only into args.data - which the multipart encoder never reads (get_multipart_data_and_content_type only consumes args.multipart_data). JSON primitive values in --multipart requests vanished silently, unlike --form, whose advertised support for the JSON field syntax is shared in the changelog. Add both separators; complex values still raise the existing 'Cannot use complex JSON value types' ParseError.
Author
|
Closing this β I don't think this change is mature enough to land right now. Thanks for the project! |
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.
--multipartsilently dropped:=and:=@JSON fields, even though the same syntax is documented (and implemented) for--form:SEPARATORS_GROUP_MULTIPARTinhttpie/cli/constants.pywas missingSEPARATOR_DATA_RAW_JSON(:=) andSEPARATOR_DATA_EMBED_RAW_JSON_FILE(:=@). Request items are routed inrequestitems.py'sProcessMultiItemArgsby that constant, so:=/:=@fields were pushed intoargs.dataβ which the multipart encoder never reads:The value vanished without an error, contradicting the changelog claim that JSON field syntax works with
--form/--multipart.Fix
Add both separators to
SEPARATORS_GROUP_MULTIPART. The existing per-value conversion (convert_json_value_to_form_if_needed) already serializes primitives to strings and raisesCannot use complex JSON value types with --form/--multipart.for complex ones β the same path--formuses β so no other code changes were needed.Tests
test_simple_json_arguments_with_non_jsonover['--form', '--multipart']β the--multipartcases fail before this change (keynever reaches the server) and pass after.test_simple_json_arguments_with_non_json_and_multipart_embedcovering:=@(complex value raises the documentedParseError; scalar value is forwarded β also fails before the change).pytest -q tests/test_json.py tests/test_uploads.py tests/test_cli.py # 364 passed