1 Commits

Author SHA1 Message Date
Zoe Forbes
68a4139251 fix: use _request() in delete_bom_entry() for consistent error handling (#59)
delete_bom_entry() used raw urllib.request instead of self._request(),
bypassing 401 auth clearing and standard error normalization. Replace
with a single _request('DELETE', ..., raw=True) call, matching the
pattern used by all other BOM methods.
2026-02-08 18:29:06 -06:00

View File

@@ -844,16 +844,7 @@ class SiloClient:
def delete_bom_entry(self, parent_pn: str, child_pn: str) -> None:
ppn = urllib.parse.quote(parent_pn, safe="")
cpn = urllib.parse.quote(child_pn, safe="")
url = f"{self.base_url}/items/{ppn}/bom/{cpn}"
headers = {"Content-Type": "application/json"}
headers.update(self._auth_headers())
req = urllib.request.Request(url, headers=headers, method="DELETE")
try:
urllib.request.urlopen(req, context=self._ssl_context())
except urllib.error.HTTPError as e:
raise RuntimeError(f"API error {e.code}: {e.read().decode()}")
except urllib.error.URLError as e:
raise RuntimeError(f"Connection error: {e.reason}")
self._request("DELETE", f"/items/{ppn}/bom/{cpn}", raw=True)
# -- Schemas ------------------------------------------------------------