Skip to content

Commit 31c851f

Browse files
Address gitar-bot review: let ValueError propagate from clean_host_port
The broad 'except Exception' in model_post_init() was swallowing the intentional ValueError that clean_host_port raises for invalid ports (e.g. 'http://localhost:abc'), leaving a malformed hostPort on the connection object and turning a clear user error into an obscure downstream failure. The local import of clean_host_port is from a sibling module that always exists, so the try/except was unnecessary defence. Removed it so pydantic surfaces validation errors where they belong.
1 parent 4418065 commit 31c851f

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

ingestion/src/metadata/ingestion/models/custom_pydantic.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,12 @@ def model_post_init(self, context: Any, /):
5555
if "hostPort" in self.__pydantic_fields__:
5656
raw = getattr(self, "hostPort", None)
5757
if isinstance(raw, str) and "://" in raw:
58-
try:
59-
from metadata.utils.db_utils import clean_host_port
60-
61-
object.__setattr__(self, "hostPort", clean_host_port(raw))
62-
except Exception:
63-
logger.warning(
64-
"Failed to clean hostPort '%s'; leaving as-is",
65-
raw[:50],
66-
)
58+
from metadata.utils.db_utils import clean_host_port
59+
60+
# Let ValueError propagate: if clean_host_port cannot parse
61+
# the input (e.g. non-numeric port), the user must fix their
62+
# config rather than silently getting a broken hostPort.
63+
object.__setattr__(self, "hostPort", clean_host_port(raw))
6764

6865
try:
6966
for field in self.__pydantic_fields__:

0 commit comments

Comments
 (0)