Fix body sending by allowing serializing strings #1057
Merged
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.
This patch refactors the resilient_client to fix a JSON double-encoding bug that caused the verifier to reject requests.
The root cause of the "malformed parameters" error from Verifier was that the
get_json_requestfunction was being called with a String that already contained JSON. The function would then re-serialize this string, wrapping it in an extra layer of quotes and escaping its contents, leading to a double-encoded payload.This PR resolves the issue by improving the client's API to be more explicit and prevent this error by design.
The original
get_json_requestfunction has been refactored. Its signature is changed to accept a pre-serialized string slice (json_string: &str) and it now uses this string directly as the request body without further serialization.A new function, get_json_request_from_struct<T: Serialize>, has been introduced. This function now contains the original logic: it takes a serializable Rust struct, converts it to a JSON string, and then calls the new get_json_request to build the request.
All call sites have been updated to use the new, more descriptive get_json_request_from_struct function, clarifying the intent to serialize a struct.
A test case in the push-model agent was also corrected to assert against the properly single-encoded JSON body.