Skip to content

Error "field X not present in Y" returned by Subsume when field does exist #3861

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

Open
GrahamDennis opened this issue Mar 29, 2025 · 0 comments · May be fixed by #3862
Open

Error "field X not present in Y" returned by Subsume when field does exist #3861

GrahamDennis opened this issue Mar 29, 2025 · 0 comments · May be fixed by #3862
Labels
NeedsInvestigation Triage Requires triage/attention

Comments

@GrahamDennis
Copy link

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

$ cue version
cue version v0.12.0

go version go1.24.1
      -buildmode exe
       -compiler gc
       -trimpath true
  DefaultGODEBUG asynctimerchan=1,gotestjsonbuildtext=1,gotypesalias=0,httpservecontentkeepheaders=1,multipathtcp=0,randseednop=0,rsa1024min=0,tls3des=1,tlsmlkem=0,x509keypairleaf=0,x509negativeserial=1,x509rsacrt=0,x509usepolicies=0
     CGO_ENABLED 1
          GOARCH amd64
            GOOS linux
         GOAMD64 v1
cue.lang.version v0.12.0

Does this issue reproduce with the latest stable release?

Yes

What did you do?

When following the Schema Definition use case example, the error returned can indicate that a field doesn't exist in the target schema instead of correctly indicating that they are not compatible.

In the example below I am determining if #V2 subsumes #v1 and then printing the errors with errors.Print:

#V1: {
    messages: Foo: crc: 32
}


#V2: {
    messages: Foo: crc: 31 | 33
}

the errors displayed are:

field Foo not present in {Foo:{crc:32}}:
    ./schema.cue:2:15
field crc not present in {crc:32}:
    ./schema.cue:2:20
field messages not present in {messages:{Foo:{crc:32}}}:
    ./schema.cue:1:6
missing field "messages"

What did you expect to see?

More useful error messages would be

31 | 33 does not subsume 32:
    ./schema.cue:2:25
    ./schema.cue:7:25
{Foo:{crc:31 | 33}} does not subsume {Foo:{crc:32}}:
    ./schema.cue:2:15
    ./schema.cue:7:15
{crc:31 | 33} does not subsume {crc:32}:
    ./schema.cue:2:20
    ./schema.cue:7:20

What did you see instead?

field Foo not present in {Foo:{crc:32}}:
    ./schema.cue:2:15
field crc not present in {crc:32}:
    ./schema.cue:2:20
field messages not present in {messages:{Foo:{crc:32}}}:
    ./schema.cue:1:6
missing field "messages"
@GrahamDennis GrahamDennis added NeedsInvestigation Triage Requires triage/attention labels Mar 29, 2025
GrahamDennis added a commit to GrahamDennis/cue that referenced this issue Mar 29, 2025
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: cue-lang#3861

Signed-off-by: Graham Dennis <[email protected]>
@GrahamDennis GrahamDennis linked a pull request Mar 29, 2025 that will close this issue
GrahamDennis added a commit to GrahamDennis/cue that referenced this issue Mar 29, 2025
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: cue-lang#3861

Signed-off-by: Graham Dennis <[email protected]>
GrahamDennis added a commit to GrahamDennis/cue that referenced this issue Mar 29, 2025
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: cue-lang#3861

Signed-off-by: Graham Dennis <[email protected]>
GrahamDennis added a commit to GrahamDennis/cue that referenced this issue Mar 29, 2025
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: cue-lang#3861

Signed-off-by: Graham Dennis <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Triage Requires triage/attention
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant