cue icon indicating copy to clipboard operation
cue copied to clipboard

cmd/cue: trim fails with "reference not found" error on correct file

Open joulaud opened this issue 3 years ago • 1 comments

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

$ cue version
cue version 0.4.0 linux/amd64

Does this issue reproduce with the latest release?

yes

What did you do?

cat <<'EOF' >x.cue
#ClusterResource: X_Platform: string
#NamespacedResource: {
	#ClusterResource
	X_Platform: string
	metadata: namespace: X_Platform
}

Resources: [Platform=string]: {
        #NamespacedResource
	X_Platform: Platform
}

Resources: myplatform: {}
EOF

cue trim x.cue

What did you expect to see?

a file not changed (or something trimmed in my more complex real use-case)

What did you see instead?

An error

 cue trim -v x.cue
#NamespacedResource.metadata.namespace: reference "_Platform" not found:
    ./x.cue:6:33

cue export and cue eval both work but not trim

joulaud avatar Oct 19 '21 10:10 joulaud

This seems like a trim bug. Trim verifies the result before rewriting to prevent a rewrite to something incorrect in case of a bug. It seems to be stripping a field that it should not remove.

mpvl avatar Oct 26 '21 12:10 mpvl