# Terraform: Error: Invalid function argument — Invalid value for "list" parameter: list of string required / Call to function "lookup" failed

**Code:** `Invalid function argument` · **Category:** Terraform · **Seen on:** Terraform

A built-in function got a wrong type/value (empty list, missing key, wrong type).

## Meaning

Read the function and parameter named. Common: `element()`/`[0]` on empty lists, `lookup()` without a default, `file()` path missing, `tonumber("abc")`, `merge` with null, `join` of non-strings. Test in `terraform console`. Use `try()`, `coalesce()`, `lookup(map, key, default)`, `length()` guards.

## Common causes

- Indexing an empty list
- `lookup` key missing and no default
- `file("path")` doesn't exist
- Type conversion failures
- Passing null to functions requiring values

## Quick fix

1. `lookup(var.map, key, null)` / `try(expr, default)`
2. Check lists with `length(x) > 0 ? x[0] : null`
3. `fileexists()` before `file()`

## Detailed fix by platform

### Terraform

1. `terraform console` then `> lookup({a=1}, "b", 0)`

## How to diagnose

1. **Function** — Which?
2. **Argument** — Type/value?
3. **Guard** — try/default?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/terraform/invalid-function-argument)
