Skip to content

metadata.display.yaml: Boolean toggle fields not visible on initial load when default is true #3399

@ashley-w-brazier-cloudm

Description

@ashley-w-brazier-cloudm

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

  1. 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
  1. 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
  1. 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:

  1. Unchecks the is_redis_standalone checkbox
  2. 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

  1. Is DISPLAY_VARIABLE_TOGGLE_TYPE_BOOLEAN intended to handle this case? If so, what is the correct YAML syntax?
  2. Should the toggle evaluator coerce boolean defaults to strings for comparison on initial load?
  3. 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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions