Bug description
When running superset set-database-uri
there are a few issues you can encounter:
- --database_name
and --uri
options are optional in the command but required in the code, leading to raised exception when either is missing instead of a user-friendly feedback.
- --skip_create
option's help text states the opposite of what it actually does: Create the DB if it doesn't exist
.
Additional context
> superset set-database-uri
Loaded your LOCAL configuration at [/app/pythonpath/superset_config.py]
2025-08-28 18:27:47,608:INFO:superset.initialization:Setting database isolation level to READ COMMITTED
2025-08-28 18:27:49,783:INFO:superset.utils.database:Creating database reference for None
Traceback (most recent call last):
File "/app/.venv/bin/superset", line 10, in <module>
sys.exit(superset())
File "/app/.venv/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
return self.main(*args, **kwargs)
File "/app/.venv/lib/python3.10/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
File "/app/.venv/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/app/.venv/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/app/.venv/lib/python3.10/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
File "/app/.venv/lib/python3.10/site-packages/click/decorators.py", line 33, in new_func
return f(get_current_context(), *args, **kwargs)
File "/app/.venv/lib/python3.10/site-packages/flask/cli.py", line 358, in decorator
return __ctx.invoke(f, *args, **kwargs)
File "/app/.venv/lib/python3.10/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
File "/app/.venv/lib/python3.10/site-packages/superset/utils/decorators.py", line 266, in wrapped
return on_error(ex)
File "/app/.venv/lib/python3.10/site-packages/superset/utils/decorators.py", line 236, in on_error
raise ex
File "/app/.venv/lib/python3.10/site-packages/superset/utils/decorators.py", line 259, in wrapped
result = func(*args, **kwargs)
File "/app/.venv/lib/python3.10/site-packages/superset/cli/update.py", line 53, in set_database_uri
database_utils.get_or_create_db(database_name, uri, not skip_create)
File "/app/.venv/lib/python3.10/site-packages/superset/utils/database.py", line 56, in get_or_create_db
database.set_sqlalchemy_uri(sqlalchemy_uri)
File "/app/.venv/lib/python3.10/site-packages/superset/models/core.py", line 386, in set_sqlalchemy_uri
conn = make_url_safe(uri.strip())
AttributeError: 'NoneType' object has no attribute 'strip'
Superset version
5.0.0
Python version
3.10
Node version
16
Browser
Chrome
Additional context
No response
Checklist
- [ ] I have searched Superset docs and Slack and didn't find a solution to my problem.
- [x] I have searched the GitHub issue tracker and didn't find a similar bug report.
- [x] I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.
Comment From: dosubot[bot]
Hi @oceantume! I'm Dosu and I’m helping the superset team.
You're correct—there are two main issues with the set-database-uri
CLI command:
-
The
--database_name
and--uri
options are defined as optional in the CLI, but the code requires them. If either is missing, the command fails with an unhandled exception instead of a user-friendly error message. This is due to the lack of validation before passing these arguments downstream, which leads to errors like'NoneType' object has no attribute 'strip'
whenuri
is omitted (source). -
The
--skip_create
flag's help text is misleading. It says "Create the DB if it doesn't exist," but when you use the flag, it actually skips database creation. The logic is inverted: setting--skip_create
prevents creation, which is the opposite of what the help text suggests (source).
For now, always provide both --database_name
and --uri
when running the command, and be aware that --skip_create
means "do not create the DB if it doesn't exist." There are no recent fixes or workarounds in the codebase for these issues.
Let me know if you need help with a workaround or want details on how to patch the CLI locally.
To reply, just mention @dosu.
How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other