thleo
thleo

Reputation: 895

In dbt, packages.yaml file gives `yaml malformed` err when adding a git package & throws invalid schema error. How can I resolve schema error?

Context: I am using a fork of a dbt package from fivetran.

I've added it under the top level packages.yml file as follows:

packages:

...

  - git: "https://github.com/thleo/dbt_mixpanel__no_quotes.git"
    revision: c0b9cc2eec45ccc7b909132f360e76278ae00c25
    name: "mixpanel__no_quotes"

When attempting to run a model that uses that package in my project, I get the following error:

  Validator Error:
  {'git': 'https://github.com/thleo/dbt_fivetran_utils__no_quotes.git', 'revision': '34722549847a7eb6be1d2a97c0eb358167a0e249', 'name': 'dbt_fivetran_utils__no_quotes', 'version': '>0.1.0'} is not valid under any of the given schemas

I'm confused on what schemas it's referring to.

I've used the YAML Language Support package from Redhat in VSCode to validate the YAML file.

I've tried all combinations of removing the quotes around the values, only having quotes around certain values...etc.

I've checked all the package.yml references in my dbt project. There is only one other projects.yml file, it's nested deeper into the project, and the only package reference is:

packages:
    - local: ../

moving around the quotes didn't lead to any different error messages, and the YAML file appears to be valid, so I'm not sure why I'm getting an error about the schema.

Upvotes: 1

Views: 253

Answers (1)

thleo
thleo

Reputation: 895

This is similar to an error called out in this ticket, and has a similar cause.

A quick explainer: for a git package, only the only required property value is git and name is not an property recognized with a git type package.

You can look here at dbt-core's project code to see how it's defined, and what the optional properties are.

According to the docs, a git package may be referenced as follows:

packages:
  - git: # your git url for the package repo (string)
    version: # optional (string, number, array)
    subdirectory: # optional (string)

So your corrected entry would look like this:

packages:
...
  - git: "https://github.com/thleo/dbt_fivetran_utils__no_quotes.git" # git URL
    revision: "34722549847a7eb6be1d2a97c0eb358167a0e249"


Resources:

  1. similar issue on dbt-core issues page (closed)
  2. git package contract definition
  3. YAML validator for dbt

Upvotes: 1

Related Questions