# Terraform: Error: Inconsistent conditional result types — The true and false result expressions must have consistent types

**Code:** `Inconsistent conditional result types` · **Category:** Terraform · **Seen on:** Terraform

A `cond ? a : b` expression returns values of different types/shapes.

## Meaning

Make both branches the same type: convert with `tolist()`, `tomap()`, `merge`, or use `null`/empty equivalents (`[]`, `{}`). With objects ensure both have the same attributes. In recent versions many cases unify automatically, but objects with different attributes don't.

## Common causes

- One branch `[]`, another object
- Objects with different attributes
- list vs set vs tuple
- string vs number
- null vs complex values

## Quick fix

1. Normalise types: `var.x != null ? var.x : {}` with matching shapes
2. Use `tolist`/`toset`/`tomap`
3. Use `try()`/`merge()` for objects

## Detailed fix by platform

### Terraform

1. `local.cfg = var.enabled ? { name = "x", size = 1 } : { name = "", size = 0 }`

## How to diagnose

1. **Branches** — Types?
2. **Shape** — Attributes?
3. **Convert** — to*()?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/terraform/inconsistent-conditional-result-types)
