## TL;DR

Jinja renders undefined variables as empty strings by default, so a macro with a missing argument silently produces nothing. Find the undefined variable by testing the macro with `dbt run-operation`, pass the argument explicitly, and add a guard that raises a clear error when required input is missing.

## Error

```text
dbt jinja macro bug: silently returning empty string
```

## Steps

1. Reproduce in isolation: `dbt run-operation [MACRO NAME] --args '{...}'` with the arguments the model passes. Expected: you see the empty output directly.
2. Add temporary debug output inside the macro to print each variable, or bisect by commenting out sections. Expected: you find which variable is undefined.
3. Fix the call site to pass the argument explicitly, or give the macro parameter a sensible default. Expected: the variable is defined on every call.
4. Add a fail-fast guard at the top of the macro that raises a clear error when required input is missing. Expected: future mistakes error loudly instead of rendering empty.
5. Recompile the affected models and verify their output. Expected: the macro renders real content.

## When to use

- A macro renders as an empty string with no error.
- Model output is missing a fragment the macro should generate.

## When not to use

- The macro raises an error (follow the traceback instead).
- The empty output is correct behavior for the inputs (then the logic is right).

## Tool compatibility

- dbt Core 1.0 and later, all adapters. Jinja undefined behavior is adapter-independent.

## Variant phrasings

### Macro works for one model but returns empty for another

The second call site passes different (or missing) arguments.

### Conditional block never renders

The condition variable is undefined, so the branch is skipped silently.

## Why it happens

Jinja's default `Undefined` type renders as an empty string instead of raising. A typo in a variable name or a missing macro argument therefore produces silence rather than an error.

## Edge cases

- `{{ config(...) }}` blocks do not render output; empty rendering there is normal.
- Filters like `default('x')` mask undefined variables; use them deliberately, not accidentally.
- Whitespace control (`-{%-`) can make empty output harder to spot in compiled SQL; check `target/compiled` directly.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_XOl96nZHjgehHPnPGeAANw
