fix: recurse through nested JSON file inputs#3036
Open
immanuwell wants to merge 1 commit into
Open
Conversation
markphelps
reviewed
Jun 1, 2026
| if mimeType == "" { | ||
| mimeType = "application/octet-stream" | ||
| } | ||
| func transformJSONValuePathsToBase64URLs(value any) (any, error) { |
Collaborator
There was a problem hiding this comment.
you didnt introduce this, and its called out in the docs that @ is reserved for file paths, but Im thinking in the future we should somehow make this more resilient or atleast make the error message better , since this will fail if a user tries to pass in @string thats not a file path. like:
{"metadata":{"handle":"@alice"}} or {"tags":["@foo"]}
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.
cog predict --jsononly rewrites top level@filevalues rn. If those paths sit inside arrays or nested objects, they go through as raw@...strings, solist[Path]style inputs via JSON are kinda busted.This makes the rewrite recursive for JSON arrays and objects. Added a unit test and an integration test too.
Repro:
cog build -t $TEST_IMAGEcog predict $TEST_IMAGE --json '{"paths": ["@1.txt", "@2.txt"]}'Before this, the CLI sends literal
@1.txtstrings and the prediction falls over.After this, those entries become data URLs and it works.
Related: #1344