Macro argument validation
| Loading table... |
dbt supports optional validation for macro arguments using the validate_macro_args flag. By default, this flag is set to false, which means that dbt won't validate the names or types of documented macro arguments.
In the past, dbt didn't enforce a standard vocabulary for the type field on macro arguments in YAML. Because of this, the type field was used for documentation only, and dbt didn't check that:
- the argument names matched those in your macro
- the argument types were valid or consistent with the macro's Jinja definition
Here's an example of a documented macro:
macros:
- name: <macro name>
arguments:
- name: <arg name>
type: <string>
When you set the validate_macro_args flag to true, dbt will:
- Validate macro arguments during project parsing.
- Check that all argument names in your YAML match those in the macro definition.
- Raise warnings if the names or types don't match.
- Validate that the
typevalues follow the supported format. - If no arguments are documented in the YAML, infer them from the macro and include them in the
manifest.jsonfile.
Impact when the flag matures
On its own, the flag emits warnings and builds continue. However, these warnings use the force-handled path and respect --warn-error, so projects with --warn-error set will see build failures at parse time.
This affects projects where the arguments: listed in a macro's YAML patch no longer match the macro's actual Jinja signature. For those projects, every command fails at parse time until you either update the YAML arguments to match the macro or remove the arguments: block entirely.
Was this page helpful?
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.