From 6b5c370c247eb0d17f5379f9690788978e0f357f Mon Sep 17 00:00:00 2001 From: elhoim Date: Sun, 30 Aug 2026 23:31:56 +0000 Subject: [PATCH] Raise when describeTypes.json 'types' field is missing or malformed get_valid_types() silently returned an empty set whenever the upstream describeTypes.json response was missing the 'types' key or had it as a non-list value. This let fetch_describe_types()'s own format check pass while valid_types stayed empty, so every subsequent invocation died later at the 'No valid MISP attribute type found.' check with no indication of the real cause (an upstream schema change). get_valid_types() now raises a RuntimeError describing the actual problem when 'types' is missing, not a list, or empty. The existing try/except around the call in main() already reports exceptions from this path as '[!] Unable to fetch describeTypes.json: ...', so the fix surfaces a specific, actionable error instead of a generic downstream failure. --- bin/cli.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/cli.py b/bin/cli.py index 92267b1..1351f3e 100644 --- a/bin/cli.py +++ b/bin/cli.py @@ -75,8 +75,10 @@ def redact_config_keys(value: Any) -> Any: def get_valid_types(describe_types: Dict[str, Any]) -> set[str]: - types = describe_types.get("types", []) - return set(types) if isinstance(types, list) else set() + types = describe_types.get("types") + if not isinstance(types, list) or not types: + raise RuntimeError("describeTypes.json 'types' field is missing, empty, or not a list") + return set(types) def get_expansion_modules(modules: List[Dict[str, Any]]) -> List[Dict[str, Any]]: