Skip to content

Commit 9945afc

Browse files
authored
Fix db_wizard when dbos-config has no database (#219)
This PR fixes the issue: The previous PR #216 introduced a bug where the db_wizard would fail if there's no database field in the dbos-config file.
1 parent ec240d8 commit 9945afc

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

dbos/_db_wizard.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import json
22
import os
33
import time
4-
from typing import TYPE_CHECKING, Optional, TypedDict
4+
from typing import TYPE_CHECKING, Optional, TypedDict, cast
55

66
import docker # type: ignore
77
import typer
@@ -50,10 +50,14 @@ def db_wizard(config: "ConfigFile", config_file_path: str) -> "ConfigFile":
5050
with open(config_file_path, "r") as file:
5151
content = file.read()
5252
local_config = yaml.safe_load(content)
53+
if "database" not in local_config:
54+
local_config["database"] = {}
55+
local_config = cast("ConfigFile", local_config)
56+
5357
if (
54-
local_config["database"]["hostname"]
55-
or local_config["database"]["port"]
56-
or local_config["database"]["username"]
58+
local_config["database"].get("hostname")
59+
or local_config["database"].get("port")
60+
or local_config["database"].get("username")
5761
or db_config["hostname"] != "localhost"
5862
or db_config["port"] != 5432
5963
or db_config["username"] != "postgres"

0 commit comments

Comments
 (0)