Skip to content

[Feature] Clarify error when file(s) contain duplicate macros #10387

@gwenwindflower

Description

@gwenwindflower

Is this a new bug in dbt-core?

  • I believe this is a new bug in dbt-core
  • I have searched the existing issues, and I could not find an existing issue for this bug

Current Behavior

Reported from a user in Community Slack.

These two listed files contain duplicate macros, but confuse users because we list the file names, not the macros. Not only that, but in my repro I discovered that we always say "two" instead of how many duplicates actually exist and only report the first two files that conflict. That last bit may not be fixable given that we error out when it happens, but I propose that ideally we should say something like:

dbt found [n] macros named "cents_to_dollars" in the project "jaffle shop".
To fix this error, rename or remove duplicates, they can be found in these files:
  - macros/hi_doug.sql
  - macros/hi_jer.sql
  - macros/cents_to_dollars.sql

My repro error from straight Core:
Screenshot 2024-07-01 at 9 56 31 AM

User from Slack's error (looks like dbt Power User):
image

Expected Behavior

I would expect dbt to give me a clearer error re which files contain all the duplicate macros

Steps To Reproduce

  1. In dbt Core
  2. Create two or three macros in different files with the same name
  3. Run a dbt compile

Relevant log output

dbt found two macros named "some_custom macro_with_sql" in the project "uft_dbt". To fix this error, rename or remove one of the following macros: - macros get_incremental_merge_insert_sq.sql - macros get _incremental_merge_update_sql.sql

Environment

- OS: MacOS 14
- Python: 3.11.8
- dbt: 1.8.0-b3

Which database adapter are you using with dbt?

snowflake

Additional Context

No response

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requesthelp_wantedTrickier changes, with a clear starting point, good for previous/experienced contributors

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions