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

LookupPath() fails to retrieve fields marked as required or optional #3449

Open
FletcherCuttingMachShip opened this issue Sep 13, 2024 · 0 comments
Labels
NeedsInvestigation Triage Requires triage/attention

Comments

@FletcherCuttingMachShip

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

cuelang.org/go v0.10.0

Does this issue reproduce with the latest stable release?

Yes

What did you do?

I have the following test:

func Test_cue(t *testing.T) {
	cuectx := cuecontext.New()
	schema := cuectx.CompileBytes([]byte(`
		person: {
			name!: string
		}
	`))

	if err := schema.Validate(); err != nil {
		t.Fatalf("failed to compile schema: %s", err)
	}

	cuePath := cue.ParsePath("person.name")

	if err := cuePath.Err(); err != nil {
		t.Fatalf("failed to parse path: %s", err)
	}

	value := schema.LookupPath(cuePath)

	if err := value.Err(); err != nil {
		t.Fatalf("failed to lookup path: %s", err)
	}
}

Worth noting: This also happens if the field has a ?.

What did you expect to see?

I expected to retrieve the person.name value without any errors.

What did you see instead?

The test failed with the following error:

failed to lookup path: person: field not found: name
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

No branches or pull requests

1 participant