Skip to content

[CT-1920] [Bug] Running dbt with state comparison fails if an exposure is disabled #6752

@rileyschack

Description

@rileyschack

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

State comparison fails (i.e. dbt run -s state:modified -t dev --state prod-target) if an exposure is disabled.

Expected Behavior

State comparison runs should work regardless if an exposure is disabled.

Steps To Reproduce

  1. Used the example dbt BigQuery project generated by dbt init with several modifications:

profiles.yml

config:
  send_anonymous_usage_stats: false

test_project:
  outputs:
    dev:
      type: bigquery
      location: us-east1
      project: sandbox
      dataset: other
      method: oauth
      priority: interactive

models/example/my_exposures.yml

version: 2
exposures:
  - name: my_first_exposure
    type: dashboard
    depends_on:
      - ref("my_second_dbt_model")
    owner:
      email: first.last@email.com
    url: my_url
    config:
      enabled: false
  1. Ran the following
dbt compile -t dev
cp -a target prod-target
  1. Updated models/example/my_first_dbt_model.sql to trigger a state change, then ran:
dbt run -s +state:modified+ -t dev --state prod-target

Relevant log output

15:02:34  Encountered an error:
Field "disabled" of type Optional[Mapping[str, List[Union[CompiledAnalysisNode, CompiledSingularTestNode, CompiledModelNode, CompiledHookNode, CompiledRPCNode, CompiledSqlNode, CompiledGenericTestNode, CompiledSeedNode, CompiledSnapshotNode, ParsedAnalysisNode, ParsedSingularTestNode, ParsedHookNode, ParsedModelNode, ParsedRPCNode, ParsedSqlNode, ParsedGenericTestNode, ParsedSeedNode, ParsedSnapshotNode, ParsedSourceDefinition]]]] in WritableManifest has invalid value {'exposure.test_project.my_first_exposure': [{'fqn': ['test_project', 'example', 'my_first_exposure'], 'unique_id': 'exposure.test_project.my_first_exposure', 'package_name': 'test_project', 'root_path': '/Users/Riley.Schack/Documents/test-project', 'path': 'example/my_exposures.yml', 'original_file_path': 'models/example/my_exposures.yml', 'name': 'my_first_exposure', 'type': 'dashboard', 'owner': {'email': 'first.last@email.com', 'name': None}, 'resource_type': 'exposure', 'description': '', 'label': None, 'maturity': None, 'meta': {}, 'tags': [], 'config': {'enabled': False}, 'unrendered_config': {'enabled': False}, 'url': 'my_url', 'depends_on': {'macros': [], 'nodes': []}, 'refs': [['my_second_dbt_model']], 'sources': [], 'created_at': 1674745117.410938, 'database': None}]}
15:02:34  Traceback (most recent call last):
  File "<string>", line 93, in from_dict
  File "<string>", line 93, in <dictcomp>
  File "<string>", line 93, in <listcomp>
  File "<string>", line 79, in __unpack_union_WritableManifest_disabled__4a2841212ee94f1c93000693a6d71a60
mashumaro.exceptions.InvalidFieldValue: Field "disabled" of type Union[CompiledAnalysisNode, CompiledSingularTestNode, CompiledModelNode, CompiledHookNode, CompiledRPCNode, CompiledSqlNode, CompiledGenericTestNode, CompiledSeedNode, CompiledSnapshotNode, ParsedAnalysisNode, ParsedSingularTestNode, ParsedHookNode, ParsedModelNode, ParsedRPCNode, ParsedSqlNode, ParsedGenericTestNode, ParsedSeedNode, ParsedSnapshotNode, ParsedSourceDefinition] in WritableManifest has invalid value {'fqn': ['test_project', 'example', 'my_first_exposure'], 'unique_id': 'exposure.test_project.my_first_exposure', 'package_name': 'test_project', 'root_path': '/Users/Riley.Schack/Documents/test-project', 'path': 'example/my_exposures.yml', 'original_file_path': 'models/example/my_exposures.yml', 'name': 'my_first_exposure', 'type': 'dashboard', 'owner': {'email': 'first.last@email.com', 'name': None}, 'resource_type': 'exposure', 'description': '', 'label': None, 'maturity': None, 'meta': {}, 'tags': [], 'config': {'enabled': False}, 'unrendered_config': {'enabled': False}, 'url': 'my_url', 'depends_on': {'macros': [], 'nodes': []}, 'refs': [['my_second_dbt_model']], 'sources': [], 'created_at': 1674745117.410938, 'database': None}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/Riley.Schack/.pyenv/versions/test-project-env/lib/python3.9/site-packages/dbt/main.py", line 135, in main
    results, succeeded = handle_and_check(args)
  File "/Users/Riley.Schack/.pyenv/versions/test-project-env/lib/python3.9/site-packages/dbt/main.py", line 198, in handle_and_check
    task, res = run_from_args(parsed)
  File "/Users/Riley.Schack/.pyenv/versions/test-project-env/lib/python3.9/site-packages/dbt/main.py", line 225, in run_from_args
    task = parsed.cls.from_args(args=parsed)
  File "/Users/Riley.Schack/.pyenv/versions/test-project-env/lib/python3.9/site-packages/dbt/task/base.py", line 186, in from_args
    return super().from_args(args)
  File "/Users/Riley.Schack/.pyenv/versions/test-project-env/lib/python3.9/site-packages/dbt/task/base.py", line 132, in from_args
    return cls(args, config)
  File "/Users/Riley.Schack/.pyenv/versions/test-project-env/lib/python3.9/site-packages/dbt/task/run.py", line 295, in __init__
    super().__init__(args, config)
  File "/Users/Riley.Schack/.pyenv/versions/test-project-env/lib/python3.9/site-packages/dbt/task/runnable.py", line 118, in __init__
    self.set_previous_state()
  File "/Users/Riley.Schack/.pyenv/versions/test-project-env/lib/python3.9/site-packages/dbt/task/runnable.py", line 122, in set_previous_state
    self.previous_state = PreviousState(
  File "/Users/Riley.Schack/.pyenv/versions/test-project-env/lib/python3.9/site-packages/dbt/contracts/state.py", line 21, in __init__
    self.manifest = WritableManifest.read_and_check_versions(str(manifest_path))
  File "/Users/Riley.Schack/.pyenv/versions/test-project-env/lib/python3.9/site-packages/dbt/contracts/util.py", line 311, in read_and_check_versions
    return cls.from_dict(data)  # type: ignore
  File "<string>", line 95, in from_dict
mashumaro.exceptions.InvalidFieldValue: Field "disabled" of type Optional[Mapping[str, List[Union[CompiledAnalysisNode, CompiledSingularTestNode, CompiledModelNode, CompiledHookNode, CompiledRPCNode, CompiledSqlNode, CompiledGenericTestNode, CompiledSeedNode, CompiledSnapshotNode, ParsedAnalysisNode, ParsedSingularTestNode, ParsedHookNode, ParsedModelNode, ParsedRPCNode, ParsedSqlNode, ParsedGenericTestNode, ParsedSeedNode, ParsedSnapshotNode, ParsedSourceDefinition]]]] in WritableManifest has invalid value {'exposure.test_project.my_first_exposure': [{'fqn': ['test_project', 'example', 'my_first_exposure'], 'unique_id': 'exposure.test_project.my_first_exposure', 'package_name': 'test_project', 'root_path': '/Users/Riley.Schack/Documents/test-project', 'path': 'example/my_exposures.yml', 'original_file_path': 'models/example/my_exposures.yml', 'name': 'my_first_exposure', 'type': 'dashboard', 'owner': {'email': 'first.last@email.com', 'name': None}, 'resource_type': 'exposure', 'description': '', 'label': None, 'maturity': None, 'meta': {}, 'tags': [], 'config': {'enabled': False}, 'unrendered_config': {'enabled': False}, 'url': 'my_url', 'depends_on': {'macros': [], 'nodes': []}, 'refs': [['my_second_dbt_model']], 'sources': [], 'created_at': 1674745117.410938, 'database': None}]}

Environment

- OS: macOS 12.6.1
- Python: 3.9.16
- dbt: 1.3.2

Which database adapter are you using with dbt?

bigquery

Additional Context

Enabled nodes in dev:

❯ dbt ls -t dev                                        
test_project.example.my_first_dbt_model
test_project.example.my_second_dbt_model
test_project.example.not_null_my_first_dbt_model_id
test_project.example.not_null_my_second_dbt_model_id
test_project.example.unique_my_first_dbt_model_id
test_project.example.unique_my_second_dbt_model_id

As soon as I change my_first_exposure to enabled: true, then state comparison works again.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions