Skip to content

[Enhancement]: schema inference does not work well for nested layout when there's dynamic fields defined #1707

Open
@Yufeireal

Description

@Yufeireal

General Question

Hi team, I've posted a question in our kcl slack channel: https://cloud-native.slack.com/archives/C05TC96NWN8/p1729279836481899
File an issue here in case it's a bug.

When defining schemas like this

schema ContainerInputs:
    maxReplicas?: int = 3

schema DeploymentInputs:
    [...str]: ContainerInputs

schema DeploymentCollectionInputs:
    [...str]: DeploymentInputs

    
    
schema NewDeploymentInputs(DeploymentInputs):
    [...str]: NewContainerInputs

schema NewContainerInputs(ContainerInputs):
    minReplicas?: int = 2

    

schema NewDeploymentCollectionInputs(DeploymentCollectionInputs):
    [...str]: NewDeploymentInputs

schema Inputs:
    vdeployments: DeploymentCollectionInputs

schema NewInputs(Inputs):
    vdeployments: NewDeploymentCollectionInputs

a = Inputs {
    vdeployments: {
        deploy_a: {
            container_a: {
                maxReplicas: 4
            }
        }
    }
}
# When trying to use inheritance, got `expect ContainerInputs, got dict`. Expect to get {minReplicas: 2, maxReplicas: 3}?
b = NewInputs {
    vdeployments: {
        deploy_b: {
            container_b: {
              minReplicas: 2
            }
        }
    }
}

Playground link

I got an error about expect ContainerInputs, but got a dict. However, if I change the initialization to be:

b = NewInputs {
    vdeployments: {
        deploy_b: {
            container_b: NewContainerInputs {
               minReplicas: 3
            }
        }
    }
}

It works.

Not sure if this is expected when base schema has dynamic fields and we does not support override those dynamic fields right now. Need some help here, thanks!

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions