From b2d515c3e0631d0a45efb1761953e2602886fecf Mon Sep 17 00:00:00 2001 From: lelia <2418071+lelia@users.noreply.github.com> Date: Tue, 2 Jun 2026 17:19:52 -0400 Subject: [PATCH] feat: add OTHER category to SocketCategory enum (CE-225) The Socket backend returns "other" as an alert category. Since v3.0.33 (commit 065407a, #79) the SDK tolerates unknown categories via a try/except fallback in SocketAlert.from_dict, but that path logs a warning that confused customers (Anthropic/Buildkite, FINRA/GitLab CI) into reporting it as a crash. Add OTHER = "other" so the value is recognized as a first-class category and the warning no longer fires. The defensive fallback is retained for any future unknown categories. Bump to 3.2.0 and sync uv.lock. Signed-off-by: lelia <2418071+lelia@users.noreply.github.com> --- pyproject.toml | 2 +- socketdev/fullscans/__init__.py | 1 + socketdev/version.py | 2 +- tests/unit/test_socket_alert_category.py | 10 ++++++++-- uv.lock | 2 +- 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 0fc8167..d6e5f17 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "socketdev" -version = "3.1.1" +version = "3.2.0" requires-python = ">= 3.9" dependencies = [ 'requests', diff --git a/socketdev/fullscans/__init__.py b/socketdev/fullscans/__init__.py index f295237..dd4c6b7 100644 --- a/socketdev/fullscans/__init__.py +++ b/socketdev/fullscans/__init__.py @@ -31,6 +31,7 @@ class SocketCategory(str, Enum): VULNERABILITY = "vulnerability" LICENSE = "license" MISCELLANEOUS = "miscellaneous" + OTHER = "other" # Added to match backend API responses class DiffType(str, Enum): diff --git a/socketdev/version.py b/socketdev/version.py index d539d50..1173108 100644 --- a/socketdev/version.py +++ b/socketdev/version.py @@ -1 +1 @@ -__version__ = "3.1.1" +__version__ = "3.2.0" diff --git a/tests/unit/test_socket_alert_category.py b/tests/unit/test_socket_alert_category.py index 02ce1c1..c55113b 100644 --- a/tests/unit/test_socket_alert_category.py +++ b/tests/unit/test_socket_alert_category.py @@ -33,8 +33,14 @@ def test_known_category_is_preserved(self): self.assertEqual(alert.category, SocketCategory.SUPPLY_CHAIN_RISK) self.assertEqual(alert.severity, SocketIssueSeverity.LOW) - def test_unknown_category_falls_back_to_miscellaneous(self): + def test_other_category_is_recognized(self): + # "other" is a known backend category as of CE-225; it should resolve to + # SocketCategory.OTHER rather than falling back to MISCELLANEOUS. alert = SocketAlert.from_dict(self._base_payload("other")) + self.assertEqual(alert.category, SocketCategory.OTHER) + + def test_unknown_category_falls_back_to_miscellaneous(self): + alert = SocketAlert.from_dict(self._base_payload("somethingCompletelyNew")) self.assertEqual(alert.category, SocketCategory.MISCELLANEOUS) def test_unknown_category_does_not_raise(self): @@ -46,7 +52,7 @@ def test_unknown_category_does_not_raise(self): def test_unknown_category_emits_warning(self): with self.assertLogs("socketdev", level=logging.WARNING) as captured: - SocketAlert.from_dict(self._base_payload("other")) + SocketAlert.from_dict(self._base_payload("somethingCompletelyNew")) self.assertTrue( any("Unknown SocketCategory" in message for message in captured.output), f"expected a warning about the unknown category, got: {captured.output}", diff --git a/uv.lock b/uv.lock index 9c96b4d..5e90720 100644 --- a/uv.lock +++ b/uv.lock @@ -1343,7 +1343,7 @@ wheels = [ [[package]] name = "socketdev" -version = "3.1.1" +version = "3.2.0" source = { editable = "." } dependencies = [ { name = "requests" },