Skip to content

Invalid check statement for string list field with regex #151

@milas

Description

@milas

Bug Report

List types with regex validation create nonsensical KCL that will attempt to run the regex against a stringified version of the collection instead of each individual element.

1. Minimal reproduce step (Required)

You can see this in the Karpenter types:

https://github.com/kcl-lang/modules/blob/7796cd48b4c2d0e33d288d7c84ae98e1788f294c/karpenter/v1/karpenter_sh_v1_node_pool.k#L337

There is a values?: [str] field, and the check is nonsensical:

_regex_match(str(values), r"^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$") if values

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

I would expect values: ["a", "b", "c"] to pass validation.

3. What did you see instead (Required)

It fails validation because str(values) turns into '[a, b, c]'.

Each value should be evaluated against the regex independently, not a stringified version of the list.

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

0.12.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions