[Bug] validate_macro_args=true with custom generic tests always warns that number of macro args doesn't match
- Dominant language
- Rust
- Stars
- 13.8k
- Forks
- 2.6k
- Avg merge
- 21h 31m
- Merged PRs (30d)
- 56
Description
### Is this a new bug in dbt-core?
- [x] I believe this is a new bug in dbt-core
- [x] I have searched the existing issues, and I could not find an existing issue for this bug
### Current Behavior
Enabling `validate_macro_args` in a project with fully documented custom generic tests causes dbt to always warn that the number of macro arguments in the yaml does not match the jinja definition.
The warning only happens when there is no existing `manifest.json` in the `target` directory.
### Expected Behavior
When `validate_macro_args` in a project with fully documented custom generic tests, dbt should not warn that there is a mismatch.
The behaviour should always be the same, regardless of whether there is an existing `manifest.json` in the `target` directory.
### Steps To Reproduce
1. Set up a dbt project with:
Python version: 3.12.9
dbt-core version: 1.10.2
2. Run `dbt init`
3. In `dbt_project.yml` enable `validate_macro_args`:
`dbt_project.yml`
```
flags:
validate_macro_args: true
```
4. Create a custom generic test by copying from the [dbt documentation on custom generic tests](https://docs.getdbt.com/best-practices/writing-custom-generic-tests#add-description-to-generic-data-test-logic:~:text=tests/generic/test_is_even,endtest%20%25%7D):
`tests/generic/test_is_even.sql`
```
{% test is_even(model, column_name) %}
with validation as (
select
{{ column_name }} as even_field
from {{ model }}
),
validation_errors as (
select
even_field
from validation
-- if this is true, then even_field is actually odd!
where (even_field % 2) = 1
)
select *
from validation_errors
{% endtest %}
```
5. Create a schema.yml file documenting the custom generic test:
`macros/generic/schema.yml`
```
macros:
- name: test_is_even
description: Test if a column value is even
arguments:
- name: model
type: string
description: Model Name
- name: column_name
type: string
description: Column name
```
6. Run `dbt parse` - note that this results in a warning in the shell:
```shell
The number of arguments in the yaml for macro test_is_even does not match the jinja definition.
```
7. Run `dbt parse` again - note that now there is a pre-existing `manifest.json` in the `target` directory there is no longer a warning.
8. Run `dbt clean && dbt parse` - note that clearing away the existing manifest before the run causes the same warning every time.
### Relevant log output
```shell
The number of arguments in the yaml for macro test_is_even does not match the jinja definition.
```
### Environment
```markdown
- OS: MacOS Sequoia 15.5
- Python: 3.12.9
- dbt-core: 1.10.2
- dbt-bigquery: 1.9.2
```
### Which database adapter are you using with dbt?
bigquery
### Additional Context
[Docs on macro argument validation](https://docs.getdbt.com/reference/global-configs/behavior-changes#macro-argument-validation)
[Docs on documenting custom generic tests](https://docs.getdbt.com/best-practices/writing-custom-generic-tests#add-description-to-generic-data-test-logic)
Contributor guide
Assessment
This issue has not been assessed yet.