Return decl attrs from Value.Attribute and preserve embed YAML tags#4272
Open
jonas-meyer wants to merge 1 commit intocue-lang:masterfrom
Open
Return decl attrs from Value.Attribute and preserve embed YAML tags#4272jonas-meyer wants to merge 1 commit intocue-lang:masterfrom
jonas-meyer wants to merge 1 commit intocue-lang:masterfrom
Conversation
Signed-off-by: Jonas Meyer-Ohle <19151471+jonas-meyer@users.noreply.github.com>
31f398c to
6041b46
Compare
There was a problem hiding this comment.
Pull request overview
This PR enhances CUE's attribute handling and YAML encoding to support declaration attributes on embedded expressions and properly preserve YAML tags. The changes enable attributes on list elements (addressing issue #4269) and fix tag preservation for embedded values.
Changes:
Value.Attributenow falls back to declaration attributes when no field attribute exists, with field attributes taking precedence- YAML encoder preserves intrinsic node tags (like
!!binary) when no explicit@yaml(,tag=...)is specified - Added support for bare
ast.Exprin declaration lists (produced byValue.Syntaxin some cases)
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| cue/attribute.go | Added fallback to declaration attributes in Value.Attribute method |
| cue/attribute_test.go | Added comprehensive tests for list element attributes and attribute precedence |
| internal/encoding/yaml/encode.go | Refactored tag extraction, added encodeEmbed function, and bare Expr handling |
| internal/encoding/yaml/encode_test.go | Added tests for binary embed tag preservation and nested list element tags |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
This PR fixes attribute lookup and YAML tag handling in two related places:
Value.Attributenow falls back to declaration attributes when no matching field attribute exists.@yaml(...,tag=...)is explicitly present.ast.Exprvalues (emitted byValue.Syntaxin some list/struct cases) are now handled consistently withEmbedDecl.!!binary).Why
Value.Attribute.tagargument was present, which changed output semantics.Addresses #4269