Skip to content

Incorrect check on optional schema parameter #443

@mihaigalos

Description

@mihaigalos

Bug Report

1. Minimal reproduce step (Required)

Tried to run the example from the docs.

schema Person:
    gender: "Male" | "Female"
    name: Name

schema Name:
    first: str
    middle?: str  # Optional, but must be non-empty when specified
    last: str

    check:
        first != ""
        last != ""
        middle != "" if middle

alice = Person {
    gender: "Female"
    name.first: "Alice"
    name.last: "White"
    name.middle: ""
}

Ran with kcl person.k.

2. What did you expect to see? (Required)

Error, since middle name is empty.

3. What did you see instead (Required)

alice:
  gender: Female
  name:
    first: Alice
    last: White
    middle: ''     <-- Expected an error on this line.

4. What is your KusionStack components version? (Required)

I don't have the folder required for this step on my machine (Kusion/kclvm-go/KCLVM), since built the binaries from source (commit 82c2be0 from March 8th).

Playground link.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions