cue icon indicating copy to clipboard operation
cue copied to clipboard

fix: Improve error message returned by Subsume

Open GrahamDennis opened this issue 8 months ago • 4 comments

Previously when Subsume determined that a field did not subsume a previous field, the error returned was:

field x not present in <value>

which is simply not true. Now a more useful error is returned in this scenario:

31 | 33 does not subsume 32:
    ./schema.cue:2:25
    ./schema.cue:7:25

Resolves: #3861

GrahamDennis avatar Mar 29 '25 00:03 GrahamDennis

Thanks for the patch. Could you add a test? Interestingly, we don't seem to have no tests for "field ... not present in ...". I would imagine this test would go somewhere under cue/testdata. Best if you add the test in a first commit, then the second commit can update the expected output and show the improvement in behavior.

mvdan avatar Mar 29 '25 00:03 mvdan

Thanks for the patch. Could you add a test? Interestingly, we don't seem to have no tests for "field ... not present in ...". I would imagine this test would go somewhere under cue/testdata. Best if you add the test in a first commit, then the second commit can update the expected output and show the improvement in behavior.

Thanks for the feedback. I've done this now.

The first commit contains just the new tests and contains some examples that I think have incorrect error messages:

-- out/TestValues/407/{foo:_1}_⊑_{foo?:_1} --
Errors:
field foo not present in {foo?:1}:
    value:1:17
missing field "foo"

Result:
false

After the second commit, the updated error message is:

-- out/TestValues/407/{foo:_1}_⊑_{foo?:_1} --
Errors:
1 does not subsume 1:
    value:1:10
    value:1:24
1 does not subsume 1?:
    value:1:10
    value:1:24

Result:
false

edit: I fixed a bug in my change with the error messages generated by the v3 evaluator vs the v2 evaluator.

GrahamDennis avatar Mar 29 '25 05:03 GrahamDennis

Ping on this PR?

GrahamDennis avatar May 14 '25 09:05 GrahamDennis

We haven't forgotten about your PRs; we're just in a bit of a crunch for the v0.13 release with the new evaluator :) Please bear with us, and thank you for your patience!

mvdan avatar May 14 '25 09:05 mvdan

ping @mvdan ? Any update here now that 0.13 is out?

GrahamDennis avatar Jun 25 '25 10:06 GrahamDennis

ping @mvdan / @mpvl ?

GrahamDennis avatar Jul 16 '25 01:07 GrahamDennis

Thanks; we haven't forgotten about this. Please understand that we have a number of competing priorities at the moment, and a small team.

mvdan avatar Jul 16 '25 20:07 mvdan

I've updated the testing setup for TestValues. It now tests for the particular error message. You can run

CUE_UPDATE=1 go test ./internal/core/subsume  

To update the generated error messages.

The reviews for this are still pending, though: https://review.gerrithub.io/c/cue-lang/cue/+/1219851/1

mpvl avatar Aug 05 '25 15:08 mpvl

Friendly nudge @GrahamDennis, not sure if you saw Marcel's replies above. You can see https://github.com/cue-lang/cue/blob/master/CONTRIBUTING.md in terms of sending patches on Gerrit.

mvdan avatar Sep 01 '25 14:09 mvdan