pulumi/changelog/pending
Zaid Ajaj 0d458a47df
[program-gen] Fix PCL bind error "cannot iterate over a value of type number" (#17569)
### Description

Often when converting terraform modules such as tf VPC module, the range
expression of resources is a conditional expression of the form `if
should_create_resource ? N : 0`.

These expressions resolve their type to one of `int`, `bool`,
`Output[int]` or `Output[bool]`. Any other type we assume we are dealing
with a collection that we are trying to iterate over. However if the
conditional expression resolves to `optional(int)` then we think it is a
collection, try to get it's key-value pair types and error with "cannot
iterate over a value of type number"

This PR fixes this problem by unwrapping `int` from `optional(int)` when
encountered in these range expressions.

I was able to isolate a subset of the converted PCL from terraform VPC
module where this problem occurs and created a unit test from it.

Interesting note is that this only occurs in _non-strict_ mode 🤔 in
strict mode, the expression type from `range` is not optional. I've not
been able to find out why that is the case yet.
2024-10-17 20:55:38 +00:00
..
20240922--engine--fix-token-expired-errors-due-to-network-issues.yaml Keep the token source loop going in the face of errors (#17519) 2024-10-08 15:16:04 +00:00
20240924--programgen-python--fix-preserving-map-keys-in-python-programgen.yaml Add a conformance test for preserving map keys (#17350) 2024-10-11 13:34:46 +00:00
20240930--sdk-go--enable-better-error-messsages-to-be-returned-from-provider-construct-failures.yaml allow better grpc error messages from Go component providers (#17464) 2024-10-10 07:13:31 +00:00
20240930--sdk-python--enable-better-error-messsages-to-be-returned-from-provider-construct-failures.yaml allow better grpc error messages from Python component providers (#17429) 2024-10-10 09:52:29 +00:00
20241003--cli--allow-memory-profile-to-be-written-occasionally-in-case-of-crash.yaml Write memory profile occasionally when profiling in case of crash/OOM. (#17461) 2024-10-09 07:33:07 +00:00
20241008--pkg--dont-publish-test-code-in-pkg-codegen.yaml Don't publish test code in `pkg/codegen` (#17517) 2024-10-09 11:09:54 +00:00
20241008--sdk-python--support-python-3-13.yaml Support Python 3.13 (#17520) 2024-10-14 09:46:16 +00:00
20241010--programgen--detect-and-error-on-binding-component-nodes-in-pcl-programs-that-self-reference-their-source.yaml [pcl] Detect and error on binding component nodes that self-reference their source (#17538) 2024-10-11 12:45:16 +00:00
20241010--yaml--update-yaml-to-1-11-1.yaml Update yaml to 1.11.1 (#17540) 2024-10-10 19:42:11 +00:00
20241011--sdk-go--improve-error-message-when-credentials-file-invalid.yaml Improve invalid credentials error message (#17541) 2024-10-11 19:23:35 +00:00
20241015--yaml--allow-pulumi-package-add-for-yaml-projects.yaml Remove `pulumi package add` error for YAML (#17560) 2024-10-15 18:45:06 +00:00
20241017--programgen--fix-pcl-bind-error-cannot-iterate-over-a-value-of-type-number-when-conditionals-are-used-in-range-expressions.yaml [program-gen] Fix PCL bind error "cannot iterate over a value of type number" (#17569) 2024-10-17 20:55:38 +00:00