Description
When using toggleUsingVariables with a boolean variable that has defaultValue: true in metadata.yaml, the conditionally toggled fields are not visible on initial page load in the Google Cloud Marketplace deployment form. The fields only become visible after the user unchecks and re-checks the boolean checkbox.
Steps to Reproduce
- Define a boolean variable with
defaultValue: true in metadata.yaml:
- name: is_redis_standalone
description: Deploy Redis as a separate VM
varType: bool
defaultValue: true
- In
metadata.display.yaml, toggle field visibility based on that boolean:
redis_vm_machine_type:
name: redis_vm_machine_type
title: Redis VM Machine Type
section: database_config
toggleUsingVariables:
- variableName: is_redis_standalone
variableValues:
- "true"
type: DISPLAY_VARIABLE_TOGGLE_TYPE_UNSPECIFIED
- Load the Marketplace deployment form.
Expected Behavior
Since is_redis_standalone defaults to true, the redis_vm_machine_type field should be visible on initial page load.
Actual Behavior
The field is hidden on initial load. It only appears after the user:
- Unchecks the
is_redis_standalone checkbox
- Re-checks it
What We've Tried
| Approach |
Result |
toggleUsingVariables (plural) + variableValues: ["true"] + DISPLAY_VARIABLE_TOGGLE_TYPE_UNSPECIFIED |
Toggle works on click, but fields hidden on initial load with default=true |
toggleUsingVariables (plural) + variableValues: ["true"] + DISPLAY_VARIABLE_TOGGLE_TYPE_BOOLEAN |
Same behavior |
toggleUsingVariables (plural) + variableValue: "true" (singular) + DISPLAY_VARIABLE_TOGGLE_TYPE_BOOLEAN |
Same behavior |
toggleUsingVariable (singular) + variableValue: "true" + DISPLAY_VARIABLE_TOGGLE_TYPE_BOOLEAN |
Unchecking no longer hides fields (singular form doesn't support toggle) |
toggleUsingVariables + type: DISPLAY_VARIABLE_TOGGLE_TYPE_BOOLEAN (no variableValues) |
Testing |
Analysis
After researching all public repositories using toggleUsingVariables:
- Zero examples of boolean variable toggles exist in any public repo
- All working examples (e.g.,
terraform-google-cloud-run, ai-on-gke/quick-start-guides) use string enum variables with DISPLAY_VARIABLE_TOGGLE_TYPE_UNSPECIFIED
- The
DISPLAY_VARIABLE_TOGGLE_TYPE_BOOLEAN enum value exists in the proto (bpmetadata_ui.proto line ~115) but has no documented usage or examples
Suspected Root Cause
The Marketplace UI renders boolean variables as checkboxes. On initial load, the toggle evaluator likely compares the variable's boolean value true against the string "true" in variableValues, which fails. On user interaction (clicking the checkbox), a coercion or re-evaluation occurs that makes the comparison succeed.
Questions
- Is
DISPLAY_VARIABLE_TOGGLE_TYPE_BOOLEAN intended to handle this case? If so, what is the correct YAML syntax?
- Should the toggle evaluator coerce boolean defaults to strings for comparison on initial load?
- Is converting boolean variables to string enums the recommended workaround?
Environment
- Marketplace Producer Portal (Terraform VM deployment)
- Blueprint metadata schema from
cloud-foundation-toolkit
- Terraform 1.5.7 (marketplace validator version)
Description
When using
toggleUsingVariableswith a boolean variable that hasdefaultValue: trueinmetadata.yaml, the conditionally toggled fields are not visible on initial page load in the Google Cloud Marketplace deployment form. The fields only become visible after the user unchecks and re-checks the boolean checkbox.Steps to Reproduce
defaultValue: trueinmetadata.yaml:metadata.display.yaml, toggle field visibility based on that boolean:Expected Behavior
Since
is_redis_standalonedefaults totrue, theredis_vm_machine_typefield should be visible on initial page load.Actual Behavior
The field is hidden on initial load. It only appears after the user:
is_redis_standalonecheckboxWhat We've Tried
toggleUsingVariables(plural) +variableValues: ["true"]+DISPLAY_VARIABLE_TOGGLE_TYPE_UNSPECIFIEDtoggleUsingVariables(plural) +variableValues: ["true"]+DISPLAY_VARIABLE_TOGGLE_TYPE_BOOLEANtoggleUsingVariables(plural) +variableValue: "true"(singular) +DISPLAY_VARIABLE_TOGGLE_TYPE_BOOLEANtoggleUsingVariable(singular) +variableValue: "true"+DISPLAY_VARIABLE_TOGGLE_TYPE_BOOLEANtoggleUsingVariables+type: DISPLAY_VARIABLE_TOGGLE_TYPE_BOOLEAN(no variableValues)Analysis
After researching all public repositories using
toggleUsingVariables:terraform-google-cloud-run,ai-on-gke/quick-start-guides) use string enum variables withDISPLAY_VARIABLE_TOGGLE_TYPE_UNSPECIFIEDDISPLAY_VARIABLE_TOGGLE_TYPE_BOOLEANenum value exists in the proto (bpmetadata_ui.protoline ~115) but has no documented usage or examplesSuspected Root Cause
The Marketplace UI renders boolean variables as checkboxes. On initial load, the toggle evaluator likely compares the variable's boolean value
trueagainst the string"true"invariableValues, which fails. On user interaction (clicking the checkbox), a coercion or re-evaluation occurs that makes the comparison succeed.Questions
DISPLAY_VARIABLE_TOGGLE_TYPE_BOOLEANintended to handle this case? If so, what is the correct YAML syntax?Environment
cloud-foundation-toolkit