use the key as path in decode error if it is a string#910
Merged
lpil merged 2 commits intogleam-lang:mainfrom Mar 7, 2026
Merged
use the key as path in decode error if it is a string#910lpil merged 2 commits intogleam-lang:mainfrom
lpil merged 2 commits intogleam-lang:mainfrom
Conversation
devstopfix
reviewed
Feb 16, 2026
| } | ||
| #(_, errors) -> push_path(#(dict.new(), errors), ["values"]) | ||
| #(_, errors) -> { | ||
| let key_identifier = case run(key, one_of(string, [])) { |
There was a problem hiding this comment.
Could this pattern be extended for integer indices into arrays also?
Here is the path I am investigating in a 29K JSON file (converted from YAML!)
expected Discriminator found Dict at paths/values/get/responses/values/content/values/schema/properties/values/items
I might be able to craft some fancy jq path - but having the keys would be a great help!
lpil
approved these changes
Mar 7, 2026
Member
lpil
left a comment
There was a problem hiding this comment.
Thank you!!! Very nice improvement
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 changes makes working with large json data, like an openapi schema, much easier.
We previously had a patch for this in OAS CrowdHailer/oas#1.
Unfortunately using the same approach in the new decode API is not possible as the decoder type is opaque.
I had a look at a previous PR attempting to do something similar #746. I didn't follow all the points discussed. I've not updated any function internals apart from the one dealing with dictionaries.