Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CT-2074] [Bug] Error message for exposures gives incorrect node type for TargetNotFound #6928

Closed
2 tasks done
callum-mcdata opened this issue Feb 9, 2023 · 2 comments · Fixed by #6934
Closed
2 tasks done
Labels
bug Something isn't working good_first_issue Straightforward + self-contained changes, good for new contributors! semantic Issues related to the semantic layer

Comments

@callum-mcdata
Copy link
Contributor

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

Assume I have the following exposure:

version: 2

exposures:

  - name: weekly_metrics
    label: Some Label
    type: dashboard
    maturity: high
    url: https://bi.tool/dashboards/1
    description: >
      Did someone say "exponential growth"?

    depends_on:
      - ref('fact_orders')
      - ref('dim_customers')
      - metric('testing')

    owner:
      name: Callum McData
      email: [email protected]

But I the node metric('testing') does not actually exist in my project. If this is the case, I get the following error message when trying to compile:

Compilation Error
Exposure 'exposure.dbt_metrics_integration_tests.weekly_metrics' (models/materialized_models/exposures.yml) depends on a source named 'testing' which was not found

This is incorrect because we can clearly see that this is a metric and not a source. When trying out the same functionality with a model node, I get the correct type displayed in the error message. IE:

depends on a node 'testing' which was not found

Expected Behavior

I would expect that the CompilationError returned by dbt core would identify the correct target node type. However, for the life of me I cannot figure out where this is coming from. I am fairly certain the error message is arising from TargetNotFoundError but I was unable to find the path that routed into there with this issue.

Steps To Reproduce

  1. Create an exposure that is referencing a metric that doesn't exist

Relevant log output

Shown in earlier messages

Environment

- OS: MacOS
- Python: 3.10
- dbt: 1.4.1

Which database adapter are you using with dbt?

postgres

Additional Context

No response

@callum-mcdata callum-mcdata added bug Something isn't working triage labels Feb 9, 2023
@github-actions github-actions bot changed the title [Bug] Error message for exposures gives incorrect node type for TargetNotFound [CT-2074] [Bug] Error message for exposures gives incorrect node type for TargetNotFound Feb 9, 2023
@jtcohen6
Copy link
Contributor

@callum-mcdata Thanks for opening! I think this is a one-liner:

if target_metric is None or isinstance(target_metric, Disabled):
# This may raise. Even if it doesn't, we don't want to add
# this node to the graph b/c there is no destination node
node.config.enabled = False
invalid_target_fail_unless_test(
node=node,
target_name=target_metric_name,
target_kind="source",
target_package=target_metric_package,
disabled=(isinstance(target_metric, Disabled)),
)
continue

target_kind should be "metric", not "source"!

@jtcohen6 jtcohen6 added good_first_issue Straightforward + self-contained changes, good for new contributors! Team:Language labels Feb 10, 2023
@callum-mcdata
Copy link
Contributor Author

@jtcohen6 yep - that's the smoking bullet right there! Tested it out on my local and it resolved the issue. Fixed via PR #6934

@jtcohen6 jtcohen6 added the semantic Issues related to the semantic layer label Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good_first_issue Straightforward + self-contained changes, good for new contributors! semantic Issues related to the semantic layer
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants