dbt-labs/dbt-core

[Bug] `packages.yml` missing `version` gives an error

dbeatty10 opened this issue · 0 comments

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

See logs below for current behavior which includes an ugly stack trace.

Expected Behavior

$ dbt deps
23:31:36  Running with dbt=1.8.0-b3
23:31:36  Encountered an error:
Runtime Error
  The packages.yml file in this project is malformed. Please double check
  the contents of this file and fix any errors before retrying.
  
  You can find more information on the syntax for this file here:
  https://docs.getdbt.com/docs/package-management
  
  Validator Error:
  dbt-labs/dbt_utils is missing the version. When installing from the Hub package index, version is a required property
  

Error encountered in dbt_project.yml

Steps To Reproduce

packages.yml

packages:
  - package: dbt-labs/dbt_utils
dbt deps

Relevant log output

$ dbt deps     
23:31:09  Running with dbt=1.8.0-b3
23:31:09  Encountered an error:
'version'
23:31:09  Traceback (most recent call last):
  File "dbt-core/core/dbt/cli/requires.py", line 106, in wrapper
    result, success = func(*args, **kwargs)
  File "dbt-core/core/dbt/cli/requires.py", line 91, in wrapper
    return func(*args, **kwargs)
  File "dbt-core/core/dbt/cli/requires.py", line 167, in wrapper
    return func(*args, **kwargs)
  File "dbt-core/core/dbt/cli/requires.py", line 200, in wrapper
    project = load_project(
  File "dbt-core/core/dbt/config/runtime.py", line 51, in load_project
    project = Project.from_project_root(
  File "dbt-core/core/dbt/config/project.py", line 764, in from_project_root
    return partial.render(renderer)
  File "dbt-core/core/dbt/config/project.py", line 333, in render
    return self.create_project(rendered)
  File "dbt-core/core/dbt/config/project.py", line 480, in create_project
    packages: PackageConfig = package_config_from_data(
  File "dbt-core/core/dbt/config/project.py", line 148, in package_config_from_data
    PackageConfig.validate(packages_data)
  File "dbt-core/core/dbt/contracts/project.py", line 119, in validate
    if not package["version"]:
KeyError: 'version'

Environment

- OS: 
- Python: 
- dbt:

Which database adapter are you using with dbt?

No response

Additional Context

Easy fix here:

if not package["version"]:

Make this change:

-                if not package["version"]:
+                if not package.get("version"):