fix(workload-identity): resolve inconsistent conditional result types in output#2582
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
There was a problem hiding this comment.
Code Review
This pull request updates the gcp_service_account output in the workload-identity module to use one(concat(...)) instead of a conditional ternary operator. This change is intended to prevent potential type mismatch issues between the data source and the resource. I have no feedback to provide as there were no review comments.
7083802 to
26d218b
Compare
… in output When use_existing_gcp_sa is unknown at plan time, Terraform fails with "Inconsistent conditional result types" because the data source and resource have slightly different object schemas. Replace the ternary with one(concat(...)) so Terraform never needs to type-check across the two branches — only one list ever has elements based on their mutually exclusive count conditions. Fixes terraform-google-modules#1112
8d584d5 to
2f8abeb
Compare
|
@apeabody @ayushmjain could one of you run |
|
/gcbrun |
|
/gcbrun |
|
@apeabody @ayushmjain could one of you review the PR the fix is ready for review. |
apeabody
left a comment
There was a problem hiding this comment.
Thanks for the contribution @raman1236!
|
/gcbrun |
Description
Fixes #1112
When
use_existing_gcp_sais unknown at plan time (e.g., comes from another resource's output), Terraform fails with:Root Cause
The
data.google_service_accountdata source andgoogle_service_accountresource return objects with slightly different attribute schemas. When Terraform can't determine which branch to evaluate at plan time, it requires both branches to have identical types.Solution
Replace the conditional expression with
one(concat(...)):This works because:
concat()doesn't require type comparison between the list elementsone()extracts the single element from the concatenated listBackward Compatibility
The output value is identical - it still returns the full GCP service account object. Only the implementation changes to avoid the type mismatch error.