You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In plugins/omi-hacker-news-app/main.py, several reliability and error-handling bugs can lead to unhandled 500 exceptions and malformed API requests:
Crash on Null or Non-Dict Request Body:get_front_page, search_stories, and get_discussion expect a payload: dict[str, Any] and call payload.get(...). When client invocations send empty/null JSON bodies or non-dict payloads, AttributeError: 'NoneType' object has no attribute 'get' is raised.
Missing item_id Type & Range Validation: In get_discussion, int(item_id) is invoked without validating whether item_id is a boolean (in Python, int(True) == 1), empty string, or non-positive integer. Sending 0 or negative numbers generates malformed requests to /items/{id}.
Boolean Handling in _safe_limit: In Python, isinstance(True, int) is True. Passing limit: True results in limit=1 instead of falling back to default 10.
Malformed URL When objectID is Missing: When Algolia returns a hit with missing objectID / story_id, _format_story constructs invalid URLs ending with item?id=None.
Proposed Solution
Add _safe_payload helper ensuring any non-dict input safely defaults to {} without raising AttributeError.
Harden _safe_limit to reject boolean values (True/False) and clamp safely between 1 and MAX_LIMIT.
Add strict validation for item_id: reject booleans, empty strings, and non-positive integers with clean error messages ("item_id must be a positive integer").
Omit or format fallback URLs cleanly when objectID is absent.
Extend test_main.py with unit tests for safe limits, non-dict payloads, missing object IDs, and item ID boundary validation.
Activity
fix(omi-hacker-news-app): guard non-dict payloads, validate item_id, …