Merged
Conversation
0fa78b6 to
c194838
Compare
This patch fixes how the encoding codec is handled across the entire codebase. Prior to this commit, support for codecs other than JSON was incomplete, mainly since the code assumed that all function output must be valid . Proper handling of codecs involves: * Validating JSON as the canonical input to function runner. * Encoding from JSON to a given codec if needed * Encoding to JSON from the function's output if needed and ensuring to keep save any encoding errors when needed. In order to achieve proper codec handling, I opted to encapsulate the details related to input and output bytes in a container (`BytesContainer`), which can either hold input or output bytes, and simiarly perform all the byte-level operations needed for reporting, such as calculating the length, presenting a human-readable representation, etc. This commit also adds the proper tests for each codec.
c194838 to
9bfb777
Compare
adampetro
reviewed
Apr 24, 2025
src/lib.rs
Outdated
| /// JSON input. | ||
| Json, | ||
| /// Raw input, no validation, passed as-is. | ||
| #[default] |
Contributor
There was a problem hiding this comment.
I would have expected Json to be the default based on this
Contributor
There was a problem hiding this comment.
Isn't this the same as echo?
| edition = "2021" | ||
|
|
||
| [dependencies] | ||
| rmpv = "1.3.0" |
Contributor
There was a problem hiding this comment.
I don't think this is used?
Contributor
Author
There was a problem hiding this comment.
Actually I wanted to decode in this test, but forgot about it. I've updated the test to do the decoding.
d85d2b6 to
1d78999
Compare
Merged
Co-authored-by: Alex Bradley <alexandre.bradley@shopify.com>
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.
This patch fixes how the encoding codec is handled across the entire codebase.
Prior to this commit, support for codecs other than JSON was incomplete, mainly since the code assumed that all function output must be valid JSON.
Proper handling of codecs involves:
In order to achieve proper codec handling, I opted to encapsulate the details related to input and output bytes in a container (
BytesContainer), which can either hold input or output bytes, and similarly perform all the byte-level operations needed for reporting, such as calculating the length, presenting a human-readable representation, etc.This commit also adds the proper tests for each codec.