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

[Bug] Current DEBUG flag access in the ManifestLoader can cause an AttributeError and is not consistent with the rest of the codebase #11068

Open
2 tasks done
Threynaud opened this issue Nov 28, 2024 · 0 comments · May be fixed by #11069
Labels
bug Something isn't working triage

Comments

@Threynaud
Copy link

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

This is a bug experienced through SQLfluff when using ManifestLoader.check_for_spaces_in_resource_names().

The way the DEBUG flag is accessed is not consistent with the rest of the codebase and can cause an error if its value is not found.

Expected Behavior

Flags are usually accessed though the get_flags() method which defaults to None.
check_for_spaces_in_resource_names() should comply with this.

Steps To Reproduce

I'm encountering this error when using sqlfluff dbt templater v3.1.0 with dbt 1.8 and above.
Any sqlfluff lint will cause this error.

Relevant log output

File "/application/.venv/bin/sqlfluff", line 8, in <module>
    sys.exit(cli())
  File "/application/.venv/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/application/.venv/lib/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/application/.venv/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/application/.venv/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/application/.venv/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/application/.venv/lib/python3.9/site-packages/sqlfluff/cli/commands.py", line 648, in lint
    result = lnt.lint_paths(
  File "/application/.venv/lib/python3.9/site-packages/sqlfluff/core/linter/linter.py", line 1065, in lint_paths
    for i, linted_file in enumerate(runner.run(expanded_paths, fix), start=1):
  File "/application/.venv/lib/python3.9/site-packages/sqlfluff/core/linter/runner.py", line 144, in run
    for lint_result in self._map(
  File "/Users/thomas/.pyenv/versions/3.9.12/lib/python3.9/multiprocessing/pool.py", line 870, in next
    raise value
  File "/Users/thomas/.pyenv/versions/3.9.12/lib/python3.9/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/Users/thomas/.pyenv/versions/3.9.12/lib/python3.9/multiprocessing/pool.py", line 144, in _helper_reraises_exception
    raise ex
  File "/Users/thomas/.pyenv/versions/3.9.12/lib/python3.9/multiprocessing/pool.py", line 388, in _guarded_task_generation
    for i, x in enumerate(iterable):
  File "/application/.venv/lib/python3.9/site-packages/sqlfluff/core/linter/runner.py", line 61, in iter_partials
    for fname, rendered in self.iter_rendered(fnames):
  File "/application/.venv/lib/python3.9/site-packages/sqlfluff/core/linter/runner.py", line 44, in iter_rendered
    for fname in self.linter.templater.sequence_files(
  File "/application/.venv/lib/python3.9/site-packages/sqlfluff_templater_dbt/templater.py", line 473, in sequence_files
    for key, node in self.dbt_manifest.nodes.items():
  File "/Users/thomas/.pyenv/versions/3.9.12/lib/python3.9/functools.py", line 993, in __get__
    val = self.func(instance)
  File "/application/.venv/lib/python3.9/site-packages/sqlfluff_templater_dbt/templater.py", line 145, in wrapped_method
    raise err
  File "/application/.venv/lib/python3.9/site-packages/sqlfluff_templater_dbt/templater.py", line 126, in wrapped_method
    result = func(*args, **kwargs)
  File "/application/.venv/lib/python3.9/site-packages/sqlfluff_templater_dbt/templater.py", line 335, in dbt_manifest
    return ManifestLoader.get_full_manifest(self.dbt_config)
  File "/application/.venv/lib/python3.9/site-packages/dbt/parser/manifest.py", line 330, in get_full_manifest
    manifest = loader.load()
  File "/application/.venv/lib/python3.9/site-packages/dbt/parser/manifest.py", line 528, in load
    self.check_for_spaces_in_resource_names()
  File "/application/.venv/lib/python3.9/site-packages/dbt/parser/manifest.py", line 647, in check_for_spaces_in_resource_names
    if improper_resource_names == 0 or self.root_project.args.DEBUG:
AttributeError: 'DbtConfigArgs' object has no attribute 'DEBUG'

Environment

- OS: MacOs Sonoma 14.0
- Python: 3.9.12
- dbt: 1.8.3

Which database adapter are you using with dbt?

bigquery

Additional Context

This would solve the following SQLFluff issue:
sqlfluff/sqlfluff#5942

@Threynaud Threynaud added bug Something isn't working triage labels Nov 28, 2024
@Threynaud Threynaud linked a pull request Nov 28, 2024 that will close this issue
@Threynaud Threynaud changed the title [Bug] Current DEBUG flag access in the ManifestLoader can cause an AttributeError and is not consitent with the rest of the codebase [Bug] Current DEBUG flag access in the ManifestLoader can cause an AttributeError and is not consistent with the rest of the codebase Nov 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant