Skip to content

Commit 8ffef98

Browse files
authored
feat: add OTHER category to SocketCategory enum (CE-225) (#85)
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>
1 parent 64d5b06 commit 8ffef98

5 files changed

Lines changed: 12 additions & 5 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "socketdev"
7-
version = "3.1.2"
7+
version = "3.2.0"
88
requires-python = ">= 3.9"
99
dependencies = [
1010
'requests',

socketdev/fullscans/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class SocketCategory(str, Enum):
3131
VULNERABILITY = "vulnerability"
3232
LICENSE = "license"
3333
MISCELLANEOUS = "miscellaneous"
34+
OTHER = "other" # Added to match backend API responses
3435

3536

3637
class DiffType(str, Enum):

socketdev/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "3.1.2"
1+
__version__ = "3.2.0"

tests/unit/test_socket_alert_category.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,14 @@ def test_known_category_is_preserved(self):
3333
self.assertEqual(alert.category, SocketCategory.SUPPLY_CHAIN_RISK)
3434
self.assertEqual(alert.severity, SocketIssueSeverity.LOW)
3535

36-
def test_unknown_category_falls_back_to_miscellaneous(self):
36+
def test_other_category_is_recognized(self):
37+
# "other" is a known backend category as of CE-225; it should resolve to
38+
# SocketCategory.OTHER rather than falling back to MISCELLANEOUS.
3739
alert = SocketAlert.from_dict(self._base_payload("other"))
40+
self.assertEqual(alert.category, SocketCategory.OTHER)
41+
42+
def test_unknown_category_falls_back_to_miscellaneous(self):
43+
alert = SocketAlert.from_dict(self._base_payload("somethingCompletelyNew"))
3844
self.assertEqual(alert.category, SocketCategory.MISCELLANEOUS)
3945

4046
def test_unknown_category_does_not_raise(self):
@@ -46,7 +52,7 @@ def test_unknown_category_does_not_raise(self):
4652

4753
def test_unknown_category_emits_warning(self):
4854
with self.assertLogs("socketdev", level=logging.WARNING) as captured:
49-
SocketAlert.from_dict(self._base_payload("other"))
55+
SocketAlert.from_dict(self._base_payload("somethingCompletelyNew"))
5056
self.assertTrue(
5157
any("Unknown SocketCategory" in message for message in captured.output),
5258
f"expected a warning about the unknown category, got: {captured.output}",

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)