Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/cue: export evaluates constraints outside the --expression flag's context inconsistently #3371

Open
jpluscplusm opened this issue Aug 15, 2024 · 1 comment

Comments

@jpluscplusm
Copy link
Collaborator

What version of CUE are you using (cue version)?

$ cue version
cue version v0.10.0

go version go1.23.0
      -buildmode exe
       -compiler gc
       -trimpath true
     CGO_ENABLED 0
          GOARCH amd64
            GOOS linux
         GOAMD64 v1
cue.lang.version v0.10.0

Does this issue reproduce with the latest stable release?

0.10.0 is latest

What did you do?

exec cue export no-package.cue -e foo
exec cue export package-p.cue  -e foo
exec cue export .:p            -e foo
exec cue export data.yml       -e foo

-- package-p.cue --
package p
foo: true
bar: false
bar: true

-- no-package.cue --
foo: true
bar: false
bar: true

-- data.yml --
foo: true
bar: false
bar: true

What did you expect to see?

I expected to see one of these outcomes:

  • all invocations succeed, as the unsatisfied constraints are outside the scope of the -e flag
  • all invocations fail, as the unsatisfied constraints are evaluated consistently across input types, despite being outside the scope of the -e flag
  • the CUE-based invocations succeed, but the YAML-based invocation fails, for some reason.

What did you see instead?

$ testscript -continue cue.export.expressionHandledDifferentlyPackageVersusFile.txtar
> exec cue export no-package.cue -e foo
[stdout]
true
> exec cue export package-p.cue  -e foo
[stdout]
true
> exec cue export .:p            -e foo
[stderr]
bar: conflicting values true and false:
    ./package-p.cue:3:6
    ./package-p.cue:4:6
[exit status 1]
FAIL: /tmp/testscript536191441/cue.export.expressionHandledDifferentlyPackageVersusFile.txtar/script.txtar:3: unexpected command failure
> exec cue export data.yml       -e foo
[stderr]
bar: conflicting values true and false:
    ./data.yml:2:6
    ./data.yml:3:6
[exit status 1]
FAIL: /tmp/testscript536191441/cue.export.expressionHandledDifferentlyPackageVersusFile.txtar/script.txtar:4: unexpected command failure

Context

I'm currently writing a concept guide for cuelang.org that explains cue export. The inconsistency highlighted above will either need to be called out explicitly, complicating the guide; or (preferably; if it's an error) corrected in the command's behaviour.

@jpluscplusm jpluscplusm added NeedsInvestigation Triage Requires triage/attention labels Aug 15, 2024
@mvdan
Copy link
Member

mvdan commented Aug 15, 2024

Thanks for filing this. From reading cue help inputs, cue export package-p.cue and cue export .:p should have exactly the same behavior, so I think this is definitely a bug.

I think all four commands should succeed, with the assumption that -e only evaluates what it needs to - and it clearly already does that in some cases.

cueckoo pushed a commit to cue-lang/cuelang.org-trybot that referenced this issue Aug 19, 2024
This adds a pair of guides explaining the "cue export" command.

A brief reference guide is added at /docs/reference/command/cue-export.
This guide is designed to accept inbound links from mentions of
cue-export from anywhere across the site. The guide's content is short:
it's limited to the minimum that communicates the role of cue-export,
whilst being written in the more formal reference-guide style. The bulk
of the technical detail around cue-export is delegated to the concept
guidet that's also added in this change.

A longer, multi-page concept guide is added at
/docs/concept/using-the-cue-export-command. A concept guide was selected
to contain the larger body of the technical material around cue-export
as it can be written with less effort than the same material would take
in the more formal reference-guide style, allowing us to get user
feedback more quickly than writing an absolutely authoritative reference
that covers cue-export exhaustively. Its somewhat more narrative and
informal style can serve a wider set of users than the reference guide
equivalent, also increasing the likelihood of user feedback.

These issues were opened during the discovery into cue-export's corner
case behaviours whilst writing these guides:
- cue-lang/cue#3368: export ignores trailing component of --path
- cue-lang/cue#3369: combining --list & --merge seems pointless
- cue-lang/cue#3371: export .:package -e evaluates entire package
- cue-lang/cue#3379: TOML errors don't include location information

Fixes cue-lang/docs-and-content#167

Preview-Path: /docs/reference/command/cue-export/
Preview-Path: /docs/concept/using-the-cue-export-command/
Preview-Path: /docs/concept/using-the-cue-export-command/inputs/
Preview-Path: /docs/concept/using-the-cue-export-command/evaluation/
Preview-Path: /docs/concept/using-the-cue-export-command/output/
Signed-off-by: Jonathan Matthews <github@hello.jonathanmatthews.com>
Change-Id: Ia4a1a326e2140081305517ba3cd9cba58aa108cd
Dispatch-Trailer: {"type":"trybot","CL":1197464,"patchset":24,"ref":"refs/changes/64/1197464/24","targetBranch":"master"}
@myitcv myitcv removed the Triage Requires triage/attention label Aug 19, 2024
cueckoo pushed a commit to cue-lang/cuelang.org-trybot that referenced this issue Oct 7, 2024
This adds a pair of guides explaining the "cue export" command.

A brief reference guide is added at /docs/reference/command/cue-export.
This guide is designed to accept inbound links from mentions of
cue-export from anywhere across the site. The guide's content is short:
it's limited to the minimum that communicates the role of cue-export,
whilst being written in the more formal reference-guide style. The bulk
of the technical detail around cue-export is delegated to the concept
guidet that's also added in this change.

A longer, multi-page concept guide is added at
/docs/concept/using-the-cue-export-command. A concept guide was selected
to contain the larger body of the technical material around cue-export
as it can be written with less effort than the same material would take
in the more formal reference-guide style, allowing us to get user
feedback more quickly than writing an absolutely authoritative reference
that covers cue-export exhaustively. Its somewhat more narrative and
informal style can serve a wider set of users than the reference guide
equivalent, also increasing the likelihood of user feedback.

These issues were opened during the discovery into cue-export's corner
case behaviours whilst writing these guides:
- cue-lang/cue#3368: export ignores trailing component of --path
- cue-lang/cue#3369: combining --list & --merge seems pointless
- cue-lang/cue#3371: export .:package -e evaluates entire package
- cue-lang/cue#3379: TOML errors don't include location information

Fixes cue-lang/docs-and-content#167

Preview-Path: /docs/reference/command/cue-export/
Preview-Path: /docs/concept/using-the-cue-export-command/
Preview-Path: /docs/concept/using-the-cue-export-command/inputs/
Preview-Path: /docs/concept/using-the-cue-export-command/evaluation/
Preview-Path: /docs/concept/using-the-cue-export-command/output/
Signed-off-by: Jonathan Matthews <github@hello.jonathanmatthews.com>
Change-Id: Ia4a1a326e2140081305517ba3cd9cba58aa108cd
Dispatch-Trailer: {"type":"trybot","CL":1197464,"patchset":25,"ref":"refs/changes/64/1197464/25","targetBranch":"master"}
cueckoo pushed a commit to cue-lang/cuelang.org-trybot that referenced this issue Oct 7, 2024
This adds a pair of guides explaining the "cue export" command.

A brief reference guide is added at /docs/reference/command/cue-export.
This guide is designed to accept inbound links from mentions of
cue-export from anywhere across the site. The guide's content is short:
it's limited to the minimum that communicates the role of cue-export,
whilst being written in the more formal reference-guide style. The bulk
of the technical detail around cue-export is delegated to the concept
guidet that's also added in this change.

A longer, multi-page concept guide is added at
/docs/concept/using-the-cue-export-command. A concept guide was selected
to contain the larger body of the technical material around cue-export
as it can be written with less effort than the same material would take
in the more formal reference-guide style, allowing us to get user
feedback more quickly than writing an absolutely authoritative reference
that covers cue-export exhaustively. Its somewhat more narrative and
informal style can serve a wider set of users than the reference guide
equivalent, also increasing the likelihood of user feedback.

These issues were opened during the discovery into cue-export's corner
case behaviours whilst writing these guides:
- cue-lang/cue#3368: export ignores trailing component of --path
- cue-lang/cue#3369: combining --list & --merge seems pointless
- cue-lang/cue#3371: export .:package -e evaluates entire package
- cue-lang/cue#3379: TOML errors don't include location information

Fixes cue-lang/docs-and-content#167

Preview-Path: /docs/reference/command/cue-export/
Preview-Path: /docs/concept/using-the-cue-export-command/
Preview-Path: /docs/concept/using-the-cue-export-command/inputs/
Preview-Path: /docs/concept/using-the-cue-export-command/evaluation/
Preview-Path: /docs/concept/using-the-cue-export-command/output/
Signed-off-by: Jonathan Matthews <github@hello.jonathanmatthews.com>
Change-Id: Ia4a1a326e2140081305517ba3cd9cba58aa108cd
Dispatch-Trailer: {"type":"trybot","CL":1197464,"patchset":26,"ref":"refs/changes/64/1197464/26","targetBranch":"master"}
cueckoo pushed a commit to cue-lang/cuelang.org-trybot that referenced this issue Oct 8, 2024
This adds a pair of guides explaining the "cue export" command.

* /docs/reference/command/cue-export/

A brief reference guide is designed to accept inbound links from
mentions of "cue export" from anywhere across the site, which will be
added in follow-up changes. The guide's content is short, as it's
intentionally limited to the minimum that communicates the core role of
"cue export" whilst being written in the formal reference-guide style.
The bulk of the technical detail around "cue export" is delegated to the
complementary concept guide.

* /docs/concept/using-the-cue-export-command/

A longer, multi-page concept guide is also added in this change. A
concept guide was selected for the larger body of the technical material
around "cue export" as it can be written with less effort than the same
material would take in the more formal reference-guide style -- allowing
us to get user feedback more quickly than if we had chosen to publish an
absolutely authoritative and exhaustive reference guide. It's also
believed that the concept guide's more narrative and informal style will
serve a somewhat wider set of users than the reference guide equivalent,
which might increase the likelihood of user feedback.

These issues were opened during the discovery into "cue export"'s corner
case behaviours whilst writing these guides:
- cue-lang/cue#3368: export ignores trailing component of --path
- cue-lang/cue#3369: combining --list & --merge seems pointless
- cue-lang/cue#3371: export .:package -e evaluates entire package
- cue-lang/cue#3379: TOML errors don't include location information

Fixes cue-lang/docs-and-content#167

Preview-Path: /docs/reference/command/cue-export/
Preview-Path: /docs/concept/using-the-cue-export-command/
Preview-Path: /docs/concept/using-the-cue-export-command/inputs/
Preview-Path: /docs/concept/using-the-cue-export-command/evaluation/
Preview-Path: /docs/concept/using-the-cue-export-command/output/
Signed-off-by: Jonathan Matthews <github@hello.jonathanmatthews.com>
Change-Id: Ia4a1a326e2140081305517ba3cd9cba58aa108cd
Dispatch-Trailer: {"type":"trybot","CL":1197464,"patchset":27,"ref":"refs/changes/64/1197464/27","targetBranch":"master"}
cueckoo pushed a commit to cue-lang/cuelang.org-trybot that referenced this issue Oct 8, 2024
This adds a pair of guides explaining the "cue export" command.

* /docs/reference/command/cue-export/

A brief reference guide is designed to accept inbound links from
mentions of "cue export" from anywhere across the site, which will be
added in follow-up changes. The guide's content is short, as it's
intentionally limited to the minimum that communicates the core role of
"cue export" whilst being written in the formal reference-guide style.
The bulk of the technical detail around "cue export" is delegated to the
complementary concept guide.

* /docs/concept/using-the-cue-export-command/

A longer, multi-page concept guide is also added in this change. A
concept guide was selected for the larger body of the technical material
around "cue export" as it can be written with less effort than the same
material would take in the more formal reference-guide style -- allowing
us to get user feedback more quickly than if we had chosen to publish an
absolutely authoritative and exhaustive reference guide. It's also
believed that the concept guide's more narrative and informal style will
serve a somewhat wider set of users than the reference guide equivalent,
which might increase the likelihood of user feedback.

These issues were opened during the discovery into "cue export"'s corner
case behaviours whilst writing these guides:
- cue-lang/cue#3368: export ignores trailing component of --path
- cue-lang/cue#3369: combining --list & --merge seems pointless
- cue-lang/cue#3371: export .:package -e evaluates entire package
- cue-lang/cue#3379: TOML errors don't include location information

Fixes cue-lang/docs-and-content#167

Preview-Path: /docs/reference/command/cue-export/
Preview-Path: /docs/concept/using-the-cue-export-command/
Preview-Path: /docs/concept/using-the-cue-export-command/inputs/
Preview-Path: /docs/concept/using-the-cue-export-command/evaluation/
Preview-Path: /docs/concept/using-the-cue-export-command/output/
Signed-off-by: Jonathan Matthews <github@hello.jonathanmatthews.com>
Change-Id: Ia4a1a326e2140081305517ba3cd9cba58aa108cd
Dispatch-Trailer: {"type":"trybot","CL":1197464,"patchset":29,"ref":"refs/changes/64/1197464/29","targetBranch":"master"}
cueckoo pushed a commit to cue-lang/cuelang.org that referenced this issue Oct 8, 2024
This adds a pair of guides explaining the "cue export" command.

* /docs/reference/command/cue-export/

A brief reference guide is designed to accept inbound links from
mentions of "cue export" from anywhere across the site, which will be
added in follow-up changes. The guide's content is short, as it's
intentionally limited to the minimum that communicates the core role of
"cue export" whilst being written in the formal reference-guide style.
The bulk of the technical detail around "cue export" is delegated to the
complementary concept guide.

* /docs/concept/using-the-cue-export-command/

A longer, multi-page concept guide is also added in this change. A
concept guide was selected for the larger body of the technical material
around "cue export" as it can be written with less effort than the same
material would take in the more formal reference-guide style -- allowing
us to get user feedback more quickly than if we had chosen to publish an
absolutely authoritative and exhaustive reference guide. It's also
believed that the concept guide's more narrative and informal style will
serve a somewhat wider set of users than the reference guide equivalent,
which might increase the likelihood of user feedback.

These issues were opened during the discovery into "cue export"'s corner
case behaviours whilst writing these guides:
- cue-lang/cue#3368: export ignores trailing component of --path
- cue-lang/cue#3369: combining --list & --merge seems pointless
- cue-lang/cue#3371: export .:package -e evaluates entire package
- cue-lang/cue#3379: TOML errors don't include location information

Fixes cue-lang/docs-and-content#167

Preview-Path: /docs/reference/command/cue-export/
Preview-Path: /docs/concept/using-the-cue-export-command/
Preview-Path: /docs/concept/using-the-cue-export-command/inputs/
Preview-Path: /docs/concept/using-the-cue-export-command/evaluation/
Preview-Path: /docs/concept/using-the-cue-export-command/output/
Signed-off-by: Jonathan Matthews <github@hello.jonathanmatthews.com>
Change-Id: Ia4a1a326e2140081305517ba3cd9cba58aa108cd
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cuelang.org/+/1197464
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants