Skip to content

Conversation

@anyapriya
Copy link
Contributor

@anyapriya anyapriya commented Sep 26, 2025

Description

Essentially undoes this PR.

While dbt did the ability to use --exclude-resource-type flag (which matches --resource-type that already exists), it is meant as a separate flag. The way this was implemented was mixing it up with the "resource_type:" tag that can be used as part of the "--select" flag - there is no corresponding "exclude_resource_type:" tag in dbt. As a result, it wasn't working the way it was intended as explained in this issue.

It's also unclear what putting a tag of exclude_resource_type into the "exclude" parameter is meant to do.

In order to add --exclude-resource-type correctly, it would need to be properly implemented as a flag instead of a tag which I think is a much bigger change.

Additionally, I can't think of any situations where this would be needed instead of using the "resource_type:" tag in the exclude parameter of the render config.

Related Issue(s)

Closes #1733

Breaking Change?

Sort of : removes functionality, but the functionality was broken.

Checklist

  • I have made corresponding changes to the documentation (if required)
  • I have added tests that prove my fix is effective or that my feature works

@netlify
Copy link

netlify bot commented Sep 26, 2025

Deploy Preview for sunny-pastelito-5ecb04 canceled.

Name Link
🔨 Latest commit a6b47f4
🔍 Latest deploy log https://app.netlify.com/projects/sunny-pastelito-5ecb04/deploys/68ef9ab2363f2f0008f4004b

@pankajastro
Copy link
Contributor

@anyapriya, are you considering these changes as a bug fix? Could you please share an example to help me better understand the issue you're trying to address?

@anyapriya
Copy link
Contributor Author

anyapriya commented Sep 29, 2025

@anyapriya, are you considering these changes as a bug fix? Could you please share an example to help me better understand the issue you're trying to address?

@pankajastro As mentioned in the linked issue, if you use the following settings:

    select=["exclude_resource_type:unit_test"],
    load_method=LoadMode.DBT_LS,

Then it results in this error:

cosmos.dbt.graph.CosmosLoadDbtException: Unable to run ['/usr/local/bin/dbt', 'ls', '--output', 'json', '--project-dir', '/tmp/tmpexno75tu', '--profiles-dir', '/tmp/cosmos/profile/147a36f81d4697b947dc02cdd963615081da6f695e3abfa1274e4e10164418b7', '--profile', 'spoileralert', '--target', 'local', '--select', 'exclude_resource_type:unit_test', '--no-partial-parse'] due to the error:
stderr: Runtime Error
  'exclude_resource_type' is not a valid method name

I think it should be removed for the following reasons:

  1. It's broken when using dbt_ls
  2. --select exclude_resource_type:unit_test and --exclude exclude_resource_type:unit_test are not valid ways to exclude a given resource type in dbt. The fact that this differs from base dbt logic selection logic is confusing. The actual ways that dbt allows are the following:
    a. --select resource_type:unit_test (docs) - possible in cosmos
    b. --exclude resource_type:unit_test (docs) - possible in cosmos
    c. --resource-type unit_test (docs) - not possible in cosmos
    d. --exclude-resource-type unit_test (docs) - not possible in cosmos
  3. It's confusing what putting exclude_resource_type:unit_test in the exclude parameter is meant to do. It looks like it select the resource type because of a double negative? But that does not seem clear. DBT doesn't run into this issue because they don't allow it.
  4. I don't think it's necessary. Not only can you achieve the intended functionality of putting exclude_resource_type:unit_test in the select, by instead putting resouce_type:unit_test in the exclude, but DBT docs say the following: "Note that the list of dbt resource types is mutually exclusive and collectively exhaustive (MECE). This means that any --resource-type selection can also be achieved by excluding the other resource types using --exclude-resource-type, and vice versa."
  5. Selecting and excluding specific tests/resource types have a different bug where they're not passed into the test tasks as mentioned in issue [Bug] exclude=["resource_type:unit_test"] not being passed #1763 and issue [Bug] Excluding unit tests from DbtTaskGroup doesn't work #1865. I have a separate PR (Allowing exclusions to be passed through to the test tasks #2006) to fix this for exclusions but fixing it for select is a lot harder. As a result, I think only allowing for putting resource_type:unit_test in the exclude is a lot safer than putting exclude_resource_type:unit_test in the select.

As mentioned in the issue, I'm open to alternative options after input from the cosmos team, but went this route after not hearing any response, and because I ultimately think it's the cleanest approach for the reasons stated above.

I think if there really is an interest in adding exclude resource type functionality, then it should be added as its own flag as a separate parameter instead of as part of the select / exclude parameters, along with the resource type flag for consistency, but that seems like a decent amount of work to implement with little value beyond what already exists.

@anyapriya
Copy link
Contributor Author

anyapriya commented Oct 1, 2025

I'm seeing that 5 tests are failing. It seems like the failing tests are due to the following:

  • 4 failing integration tests due to "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential." see here
  • 1 failing Type-Check test - this is failing in other PRs too like this one , looks like it's planned to be fixed here

Neither seems related to this PR, would love recommendation from the cosmos team on how to handle this

@pankajastro
Copy link
Contributor

pankajastro commented Oct 3, 2025

@tatiana, the issue #1530 mentioned to support --exclude-resource-type for LoadMode.MANIFEST and LoadMode.CUSTOM. Why not the DBT_LS?

@pankajastro pankajastro requested a review from Copilot October 3, 2025 12:18
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR removes the broken exclude_resource_type functionality that was incorrectly implemented as a tag-based selector instead of a proper flag. The functionality was not working as intended because it mixed up dbt's --exclude-resource-type flag with selector syntax.

  • Removes all exclude_resource_type selector code and related functionality
  • Updates documentation to remove references to the broken feature
  • Removes associated tests that were testing the broken implementation

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
cosmos/dbt/selector.py Removes exclude_resource_type selector constants, parsing logic, and filtering methods
docs/configuration/selecting-excluding.rst Updates documentation to remove exclude_resource_type selector reference
tests/dbt/test_selector.py Removes test cases for the broken exclude_resource_type functionality

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@codecov
Copy link

codecov bot commented Oct 3, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.77%. Comparing base (78fb5db) to head (57e8b54).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2005      +/-   ##
==========================================
+ Coverage   97.06%   97.77%   +0.71%     
==========================================
  Files          91       91              
  Lines        5862     5850      -12     
==========================================
+ Hits         5690     5720      +30     
+ Misses        172      130      -42     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tatiana
Copy link
Collaborator

tatiana commented Nov 13, 2025

@anyapriya I agree with your analysis. It was a mistake to accept that contribution. I'm talking to the original contributor of this feature next week to confirm the possibility of them changing how they accomplish this, before we go ahead to remove the feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] exclude_resource_type doesn't work in select / exclude with dbt ls in cosmos

3 participants