Closed gesmit74 closed 2 weeks ago
Hello @gesmit74 Could you please provider a simple case that can reproduce this error? I try the following code and I can't reproduce this error and what's your KCL version before?
schema Service:
"""The service model."""
$type?: str = "ClusterIP"
port: int
_service = Service{port = 800}
_service.port = 80
service = _service
Also I've tried the following code.
schema Service:
"""The service model."""
$type?: str = "ClusterIP"
port: int
service.port = 80
It produces this error
Error: EvaluationError
--> test.k:6:1
|
6 | service.port = 80
| failed to update the dict. An iterable of key-value pairs was expected, but got UndefinedType. Check if the syntax for updating the dictionary with the attribute 'port' is correct
|
I've been using all version from 0.9 As soon as there was an update, I updated my local versions too. This just happened this morning after updating to the latest v0.10.0 I have indeed the second code in my files. It happens on more places, too many to post them all, but they all follow the same rules
I see. We have provided a new evaluator implementation in KCL v0.9. x version, which can be enabled by KCL_FAST_EVAL=1
and is turned off by default. However, in v0.10.0, it is turned on by default, which may cause regression issues. It would be great if you could provide a minimal use case to reproduce it, and we can fix it in v0.10.1.
Thank you for the feedback. The most minimal use case would be
schema Service:
"""The service model."""
$type?: str = "ClusterIP"
port: int
service.port = 80
other case I came across:
schema container:
resources?: Resources
schema Resources:
cpu?: str
memory?: str
cpuLimit?: str
memoryLimit?: str
ephemeralStorage: str = "2G"
container.resources = {
cpu = "250m"
memory = "256Mi"
cpuLimit = "1500m"
memoryLimit = "512Mi"
}
EvaluationError --> test/app.k:37:1 | 37 | memoryLimit = "512Mi" | TypeError: argument of type 'UndefinedType' is not iterable |
---|
note: backtrace: 0: kclvm_main at test/app.k:37
Hello, @gesmit74
Can you provide a more accurate example? I cannot reproduce the error from your example.
Error: EvaluationError
--> test.k:6:1
|
6 | service.port = 80
| failed to update the dict. An iterable of key-value pairs was expected, but got UndefinedType. Check if the syntax for updating the dictionary with the attribute 'port' is correct
|
Another error is
error[E1001]: ImmutableError
--> test.k:11:1
|
11 | container.resources = {
| ^ Can not change the value of 'container', because it was declared immutable
|
--> /Users/lingzhi/_Code/KCLOpenSource/lib/a.k:1:1
|
1 | schema container:
| ^ The variable 'container' is declared here
|
note: change the variable name to '_container' to make it mutable
When creating a minimal reproduction, I discovered that I formatted the build file using kcl format. This broke everything. After reverting, generation works again. Sorry for the issue.
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
Define a schema:
Simply add to your config:
service.port = 80
2. What did you expect to see? (Required)
That the service port is processed like before without any unexpected errors
3. What did you see instead (Required)
4. What is your KCL components version? (Required)
kcl --version kcl version 0.10.0