vscode-dbt-power-user: Runtime Error 'NoneType' object has no attribute 'find_generate_macro_by_name'

Expected behavior

When trying to run any jinja templated SQL, the extension is able to compile the SQL and run the query correctly against the data warehouse

Actual behavior

When trying to run any jinja templated SQL, the extension throws an error:

Runtime Error 'NoneType' object has no attribute 'find_generate_macro_by_name'

{
  "code": -1,
  "message": "Runtime Error\n  Runtime Error\n    'NoneType' object has no attribute 'find_generate_macro_by_name'",
  "data": "\"Error: Traceback (most recent call last):\\n  File \\\"c:\\\\Users\\\\me\\\\.vscode\\\\extensions\\\\innoverio.vscode-dbt-power-user-0.10.1\\\\dist\\\\dbt_integration.py\\\", line 447, in compile_sql\\n    node = self.compile_node(self.get_server_node(raw_sql, temp_node_id))\\n  File \\\"c:\\\\Users\\\\me\\\\.vscode\\\\extensions\\\\innoverio.vscode-dbt-power-user-0.10.1\\\\dist\\\\dbt_integration.py\\\", line 373, in get_server_node\\n    sql_node = self.sql_parser.parse_remote(sql, node_name)\\n  File \\\"c:\\\\Users\\\\me\\\\.vscode\\\\extensions\\\\innoverio.vscode-dbt-power-user-0.10.1\\\\dist\\\\dbt_integration.py\\\", line 266, in sql_parser\\n    self._sql_parser = SqlBlockParser(self.config, self.dbt, self.config)\\n  File \\\"c:\\\\Users\\\\me\\\\Projects\\\\de-dbt\\\\.venv\\\\lib\\\\site-packages\\\\dbt\\\\parser\\\\base.py\\\", line 105, in __init__\\n    self._update_node_database = RelationUpdate(\\n  File \\\"c:\\\\Users\\\\me\\\\Projects\\\\de-dbt\\\\.venv\\\\lib\\\\site-packages\\\\dbt\\\\parser\\\\base.py\\\", line 74, in __init__\\n    macro = manifest.find_generate_macro_by_name(\\nAttributeError: 'NoneType' object has no attribute 'find_generate_macro_by_name'\\n\\nDuring handling of the above exception, another exception occurred:\\n\\nTraceback (most recent call last):\\n  File \\\"c:\\\\Users\\\\me\\\\.vscode\\\\extensions\\\\innoverio.vscode-dbt-power-user-0.10.1\\\\dist\\\\dbt_integration.py\\\", line 409, in execute_sql\\n    compilation_result = self.compile_sql(raw_sql)\\n  File \\\"c:\\\\Users\\\\me\\\\.vscode\\\\extensions\\\\innoverio.vscode-dbt-power-user-0.10.1\\\\dist\\\\dbt_integration.py\\\", line 451, in compile_sql\\n    raise RuntimeException(str(e))\\ndbt.exceptions.RuntimeException: Runtime Error\\n  'NoneType' object has no attribute 'find_generate_macro_by_name'\\n\\nDuring handling of the above exception, another exception occurred:\\n\\nTraceback (most recent call last):\\n  File \\\"c:\\\\Users\\\\me\\\\.vscode\\\\extensions\\\\innoverio.vscode-dbt-power-user-0.10.1\\\\dist\\\\node_python_bridge.py\\\", line 104, in <module>\\n    value = eval(_compile(data['code'], '<input>', 'eval'), _locals)\\n  File \\\"<input>\\\", line 1, in <module>\\n  File \\\"c:\\\\Users\\\\me\\\\.vscode\\\\extensions\\\\innoverio.vscode-dbt-power-user-0.10.1\\\\dist\\\\dbt_integration.py\\\", line 418, in execute_sql\\n    raise RuntimeException(str(e))\\ndbt.exceptions.RuntimeException: Runtime Error\\n  Runtime Error\\n    'NoneType' object has no attribute 'find_generate_macro_by_name'\\n\\n\\tat ChildProcess.onMessage (c:\\\\Users\\\\me\\\\.vscode\\\\extensions\\\\innoverio.vscode-dbt-power-user-0.10.1\\\\dist\\\\extension.js:4796:184)\\n\\tat Object.onceWrapper (node:events:646:26)\\n\\tat ChildProcess.emit (node:events:526:28)\\n\\tat emit (node:internal/child_process:938:14)\\n\\tat process.processTicksAndRejections (node:internal/process/task_queues:84:21)\""
}

Steps To Reproduce

Exact steps to reproduce are not clear. It maybe environment specific

Log output/Screenshots

No response

Operating System

Windows 11 Pro. Version 10.0.22000 Build 22000

dbt version

1.3.1

dbt Adapter

dbt-snowflake

dbt Power User version

0.10.1

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 7
  • Comments: 45 (11 by maintainers)

Most upvoted comments

FYI I had this issue as well and dbt clean && dbt deps did not solve it for me.

Turns out it was caused by a column definition being duplicated. I ran dbt ls at some point and got the following error:

Encountered an error:
Compilation Error
  dbt found two tests with the name "not_null_stg_promotion_supplier_contribution_sku" defined on column "sku" in "models.stg_promotion_supplier_contribution".
  
  Since these resources have the same name, dbt will be unable to find the correct resource
  when running tests.
  
  To fix this, change the name of one of these resources:
  - test.pieter_pot_dwh.not_null_stg_promotion_supplier_contribution_sku.32d077df59 (models/staging/promotions/stg_promotions.yml)
  - test.pieter_pot_dwh.not_null_stg_promotion_supplier_contribution_sku.32d077df59 (models/staging/promotions/stg_promotions.yml)

And so I found the column and test that were duplicate. Hope this helps

Thank you @sdepablos 🙌 that solved it!

@food-spotter have you tried dbt clean & dbt deps? In our case it solved the issue (happened to us right now)

Same issue for me after upgrades to 1.4.3 for core and adapters. Rolled my environment back dbt-core==1.4.1 dbt-databricks==1.4.1 dbt-postgres==1.4.1. Retained v 0.11.5 of dbt Power User and back I’m back up and running. This was occuring both on my MacOS and Windows environments.

That’s an actionable problem that can be detected by the extension. Thanks @sdepablos for helping understand this.

I’ll keep the issue open until I add detection for this issue and show a warning.

reinstalling the extension somehow works for me

Just solved this after hours of unsuccessfully trying pretty much every installation combination possible. What worked in the end was simply uninstalling and installing the extension in VS code. Finally I can see the results of queries. However I must say that before if I ran any dbt command in the CLI such as run or seed, it did work in the CLI, I just couldn’t use anything from the extension.

Hello,

I had a colleague who had the same problem. Turns out she was launching VSCode straight from her /Downloads folder, she had never moved the application into the /Applications folder. The issue was solved by moving the app into the /Applications folder.

Works for me. Thanks a lot @mdesmet 💪

Thanks, that’s a good pointer. I’ll try to fix it.

It might be a cache conflict. I’ll dig into this in the next weeks.

Our team was running into this on Github Codespaces - just disabling and reenabling the extension solved it so seems something at the setup stage.

I can confirm that the exact same repo (git clone) works fine on my other machine (MacOS Monterey 12.6, same dbt version, same python version 3.9). It only happens on the Windows machine mentioned above. It is not an intermittent issue.