-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[CT-750] [Bug] Raise helpful error if user provides "dbt" as project name during dbt init
#5379
Comments
@philippefutureboy Thanks for opening!
Fair :) For good reason, I don't think we're going to be able to support A better behavior here would be to raise that validation error earlier, during the dbt-core/core/dbt/task/init.py Lines 257 to 265 in 6572b7e
It should be fairly simple to check that the user-provided project name doesn't match from dbt.include.global_project import PROJECT_NAME as GLOBAL_PROJECT_NAME It would be a bit trickier to check that the user-provided name also doesn't collide with one of the installed plugins' reserved package names ( def get_valid_project_name(self) -> str:
"""Returns a valid project name, either from CLI arg or user prompt."""
name = self.args.project_name
internal_package_names = set({GLOBAL_PROJECT_NAME})
available_adapters = list(_get_adapter_plugin_names())
for adapter_name in available_adapters:
internal_package_names.add(get_adapter_package_names(adapter_name))
while not (ProjectName.is_valid(name) or name in internal_package_names):
if name:
click.echo(name + " is not a valid project name.")
name = click.prompt("Enter a name for your project (letters, digits, underscore)")
return name There are pretty thorough tests for I'm going to mark this one as |
dbt init
Hi @jtcohen6 ! That's a great explainer! I didn't even realize the problem was the project name, instead of the folder name! For me that's great news because I mind more the folder structure than the project name tbh :)
I'm going to have to say no. I would love to but I know I can't hold that promise. Thanks for asking! Hopefully this will be a great entrypoint for a new prolific contributor :) Cheers! 🥂 |
Hi @jtcohen6, I can take on this issue I was looking for something to start dipping my toes in the project |
Hi @jtcohen6, the following line generates the error when calling dbt init: "No plugin found for postgres" internal_package_names.add(get_adapter_package_names(adapter_name)) It looks like get_adapter_package_names cannot find the package name, however adapter_name is correct ("postgres"). |
Is there an existing issue for this?
Current Behavior
Given the following setup
I get the following output:
Which was pretty confusing at first until I figured out the issue was the top level folder name.
As a first-time user of dbt, that's a kind of weird way to get this relationship started 🥴
Expected Behavior
Allow top level folder to be named dbt :)
Since we are using dbt in the context of apache airflow, I think that structurally speaking it's an acceptable & reasonable way to structure the folder hierarchy:
Steps To Reproduce
No response
Relevant log output
No response
Environment
What database are you using dbt with?
bigquery
Additional Context
I searched but could not find an equivalent issue. Feel free to mark as duplicate if I missed something.
Related: #2029
For the time being I'll just rename the folder something else.
The text was updated successfully, but these errors were encountered: