Skip to content

Cue: Enums with defaults generating wrong types#1069

Open
spinillos wants to merge 2 commits intomainfrom
cue/enums-with-defaults-generating-wrong-types
Open

Cue: Enums with defaults generating wrong types#1069
spinillos wants to merge 2 commits intomainfrom
cue/enums-with-defaults-generating-wrong-types

Conversation

@spinillos
Copy link
Copy Markdown
Member

When we have:

Enum: "A" | "B"
EnumWithDefault: *"C" | "D"

Cue parser detects A, B and D discriminators as constant references, when C was detected as reference. The constant reference is the same as reference but with a specific value.

When we use EnumWithDefault values as discriminator, being C as reference, we weren't able to detect its value, generating any/interface{} instead of the proper intermediate structure.

You can check in the test, that now we have this for all discriminator values:

"Type": {
    "Kind": "constant_ref",
    "Nullable": false,
    "ConstantReference": {
        "ReferredPkg": "grafanatest",
        "ReferredType": "Enum1",
        "ReferenceValue": "A"
    }
},

@spinillos spinillos self-assigned this Apr 10, 2026
@spinillos spinillos requested a review from a team as a code owner April 10, 2026 16:42
@spinillos spinillos added bug Something isn't working area:parsers labels Apr 10, 2026
@github-actions
Copy link
Copy Markdown

Note: the diff show code changes that would be introduced by this PR to the output of the Grafana Foundation SDK codegen pipeline.

See full diff.

🔎 Changes to Grafana Foundation SDK

@spinillos spinillos requested a review from IfSentient April 10, 2026 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:parsers bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant