z3z1ma / dbt-osmosis

Provides automated YAML management, a dbt server, streamlit workbench, and git-integrated dbt model output diff tools
https://z3z1ma.github.io/dbt-osmosis/
Apache License 2.0
456 stars 46 forks source link

Fix edge case errors when forgetting to register model name in schema.yml. #119

Closed yassun7010 closed 9 months ago

yassun7010 commented 10 months ago

Hi!

I found the edge case bug.

When model sql file exists in models folder without model name does not register in schema.yml, dbt-osmosis yaml refactor is failed.

The error messages I have encountered are as follows:

Traceback (most recent call last):
  File "/Users/s23467/Library/Caches/pypoetry/virtualenvs/aoc-akagi-cdp-dbt-Pv9R6Ian-py3.11/bin/dbt-osmosis", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/Users/s23467/Library/Caches/pypoetry/virtualenvs/aoc-akagi-cdp-dbt-Pv9R6Ian-py3.11/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/s23467/Library/Caches/pypoetry/virtualenvs/aoc-akagi-cdp-dbt-Pv9R6Ian-py3.11/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/Users/s23467/Library/Caches/pypoetry/virtualenvs/aoc-akagi-cdp-dbt-Pv9R6Ian-py3.11/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/s23467/Library/Caches/pypoetry/virtualenvs/aoc-akagi-cdp-dbt-Pv9R6Ian-py3.11/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/s23467/Library/Caches/pypoetry/virtualenvs/aoc-akagi-cdp-dbt-Pv9R6Ian-py3.11/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/s23467/Library/Caches/pypoetry/virtualenvs/aoc-akagi-cdp-dbt-Pv9R6Ian-py3.11/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/s23467/Library/Caches/pypoetry/virtualenvs/aoc-akagi-cdp-dbt-Pv9R6Ian-py3.11/lib/python3.11/site-packages/dbt_osmosis/main.py", line 80, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/s23467/Library/Caches/pypoetry/virtualenvs/aoc-akagi-cdp-dbt-Pv9R6Ian-py3.11/lib/python3.11/site-packages/dbt_osmosis/main.py", line 216, in refactor
    if runner.commit_project_restructure_to_disk():
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/s23467/Library/Caches/pypoetry/virtualenvs/aoc-akagi-cdp-dbt-Pv9R6Ian-py3.11/lib/python3.11/site-packages/dbt_osmosis/core/osmosis.py", line 692, in commit_project_restructure_to_disk
    if structure.output["sources"]:
       ~~~~~~~~~~~~~~~~^^^^^^^^^^^
KeyError: 'sources'
yassun7010 commented 10 months ago

Oh, I found same PR in https://github.com/z3z1ma/dbt-osmosis/pull/118.

yassun7010 commented 9 months ago

https://github.com/z3z1ma/dbt-osmosis/pull/118 was merged.

This issue is now closed.