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

Better error messages #445

Merged
merged 7 commits into from
May 24, 2017
Merged

Better error messages #445

merged 7 commits into from
May 24, 2017

Conversation

drewbanin
Copy link
Contributor

Better error messages for #294

No profile specified in dbt_project.yml or provided on CLI. No profiles.yml file

$ dbt run
Encountered an error while reading the project:
dbt cannot run because no profile was specified for this dbt project.
To specify a profile for this project, add a line like the this to
your dbt_project.yml file:

profile: [profile name]

Here, [profile name] should be replaced with a profile name
defined in your profiles.yml file. You can find profiles.yml here:

/Users/drew/.dbt/profiles.yml

There are no profiles defined in your profiles.yml file

For more information on configuring profiles, please consult the dbt docs:

https://dbt.readme.io/docs/configure-your-profile

Encountered an error:
Could not run dbt

profiles.yml not found (but a profile is specified in dbt_project.yml)

$ dbt run
Encountered an error while reading the project:
Could not find profile named 'default'
There are no profiles defined in your profiles.yml file

For more information on configuring profiles, please consult the dbt docs:

https://dbt.readme.io/docs/configure-your-profile

Encountered an error:
Could not run dbt

profiles.yml contains invalid yaml

$ dbt run
Encountered an error:

dbt encountered an error while trying to read your profiles.yml file.

Syntax error near line 11
------------------------------
8  |   target: dev
9  |   outputs:
10 |     dev
11 |       type: postgres
12 |       host: localhost
13 |       user: drew

Raw Error:
------------------------------
mapping values are not allowed here
  in "<unicode string>", line 11, column 11:
          type: postgres
              ^

Invalid yaml in a schema.yml file:

$ dbt test
Error reading package_name:base/schema.yml - Skipping
Syntax error near line 16
------------------------------
13 |         not_null
14 |             - now
15 |
16 |         unique:
17 |             - now
18 |

Raw Error:
------------------------------
mapping values are not allowed here
  in "<unicode string>", line 16, column 15:
            unique:
                  ^

@cmcarthur let me know if you think i went overboard here...

@drewbanin drewbanin added this to the 0.8.2 Release milestone May 24, 2017
@drewbanin drewbanin requested a review from cmcarthur May 24, 2017 01:58
Copy link
Member

@cmcarthur cmcarthur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should spend a couple minutes cleaning up yaml_helper.py. beyond that, this looks excellent.

return yaml.safe_load(contents)
except (yaml.scanner.ScannerError, yaml.YAMLError) as e:
if hasattr(e, 'problem_mark'):
error = contextualized_yaml_erro(contents, e)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

contextualized_yaml_error?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦‍♂️

else:
error = dbt.compat.to_string(e)

raise dbt.exceptions.ValidationException(error)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is great, but the code here is a little rough around the edges.

@drewbanin
Copy link
Contributor Author

@cmcarthur good points -- i think this is ready for another look

@drewbanin drewbanin merged commit e9177e2 into development May 24, 2017
@drewbanin drewbanin deleted the better-error-messages branch May 24, 2017 16:34
iknox-fa pushed a commit that referenced this pull request Feb 8, 2022
* wip

* overhauled yaml validation error messages

* use yaml client (mostly) everywhere

* fix imports

* fix yaml client namespace for python2

* pep8

* code cleanup + typos


automatic commit by git-black, original commits:
  e9177e2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants