Repository navigation
fix(clickup-app): harden error handling, null guards, session lifecycle, and type coercion (#14267) - #14268
Conversation
…le, and type coercion (BasedHardware#14267) Harden plugins/omi-clickup-app against unbounded session memory leaks, non-dict/HTML gateway outage payloads, non-numeric assignee IDs, and eager OpenAI client initialization. - simple_storage.py: implement bounded session lifecycle methods (delete_session and cleanup_old_sessions) and migrate to timezone-aware UTC timestamps. - clickup_client.py: implement _safe_json defensive parsing; add null and non-dict guards across spaces, lists, folders, and workspace members; safely coerce assignee IDs to integers and normalize due date and status handling. - task_detector.py: decouple OpenAI client into lazy get_openai_client() with graceful deterministic fallbacks and null-safe list/member parsing. - main.py: add _extract_segment_texts helper, safe list lookups, and periodic session cleanup in monitor_session_timeouts. - omi_notifications.py: dynamic credentials and safe exception logging. - test_clickup_client.py: expand from 5 to 37 hermetic unit tests running in <0.05s under pure stdlib (python3 -S). Fixes BasedHardware#14267 PayPal: [email protected] Failure-Class: none
…ponse for stdlib test runners (BasedHardware#14267) Avoid evaluating requests.Response at import time in environments where requests is stubbed or uninstalled, and stub Response/RequestException on the test requests module stub. Failure-Class: none
|
Resolved CI import evaluation issue in commit
PayPal: [email protected] |
…asedHardware#14267) Resolve NameError on Any during class definition under Python runtimes evaluating annotations at class creation time. Failure-Class: none
|
All checks green: added missing PayPal: [email protected] |
|
Thanks @TheRWX — reviewed this against issue #14267 and verified it locally: all six modules compile, and the expanded hermetic suite passes 37/37 offline (requests/dotenv/fastapi/openai stubbed, no network, no secrets). This is a cohesive hardening pass, well scoped to the plugin. Per-file notes:
Two non-blocking observations for a possible follow-up:
Separately, and pre-existing rather than introduced here: OAuth access tokens are stored in plain JSON at rest. Not this PR's job to solve, but worth a maintainers' conversation. Overall this is in good shape — leaving the merge decision with the maintainers. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
Git-on-my-level
left a comment
There was a problem hiding this comment.
Reviewed all 6 files at head 3bfd2a2. Verdict: approve.
- clickup_client.py:
_safe_jsonguards non-JSON bodies; every list/dict accessor isinstance-checked;get_all_listspreserves the #13808 fail-closed folder contract (folder walk failure → [] rather than a silently short picker);create_taskcoerces priority/assignees/due_date and returns structured error dicts instead of raising. - main.py / task_detector.py / omi_notifications.py: import-time
AsyncOpenAI(...)and credential crashes replaced with lazy getters; monitor loop evicts sessions every 60 ticks (SimpleSessionStorage.cleanup_old_sessions); error prints emit exception type only, no payloads. - simple_storage.py: naive
datetime.utcnow()→ tz-awaredatetime.now(timezone.utc)with tzinfo backfill for legacy stamps;update_timezoneno longer shadows thetimezoneimport; bounded session eviction added. - Verified locally at head:
python3 plugins/omi-clickup-app/test_clickup_client.py→ 37/37 OK;test_settings_page.py→ 2/2 OK. Both suites are already CI-wired via checks-manifest.
CI green on this head (no fail/pending), merge-tree clean vs 75e42d3. No open review threads.
Description
This PR resolves #14267 by hardening
plugins/omi-clickup-app/against in-memory session leaks, non-dict/HTML gateway outage payloads, non-numeric assignee IDs, due date variations, and unhandled exceptions:Session Lifecycle Management & Memory Leak Remediation (
simple_storage.py):delete_session(session_id: str) -> boolandcleanup_old_sessions(max_age_seconds: int = 3600) -> intto evict expired or abandoned sessions from the globalsessionsdictionary.monitor_session_timeoutsinmain.py.datetime.utcnow()to timezone-aware UTC timestamps (datetime.now(timezone.utc)).Defensive Response Parsing & Null Guards (
clickup_client.py):_safe_json(response)helper ensuring gateway error pages (HTML 502/504) or malformed payloads do not raiseAttributeErrororJSONDecodeError.get_spaces,get_lists,get_folders,get_folder_lists, andget_workspace_membersagainstNonecollections, non-dict list items, and missing keys.Resilient Parameter Coercion (
clickup_client.py):create_task: safely coerced assignee IDs to integers viatry/except (ValueError, TypeError), dropping non-numeric strings (e.g."me","admin") without throwing unhandled exceptions.statuswhether returned as a nested dictionary ({"status": "..."}), a string, orNone.Decoupled OpenAI Client Initialization (
task_detector.py):get_openai_client().ai_extract_task_detailsandai_match_listwhen the client or API key is not configured.Defensive Transcript Processing (
main.py):_extract_segment_textshelper safely extracting non-empty string texts from transcript segment arrays.task_contentand protectedselected_listlookups against non-dict items.Notification Safety (
omi_notifications.py):get_omi_credentials()for dynamic runtime loading and sanitized exception logging to avoid AST log safety tripwires.Expanded Hermetic Test Suite (
test_clickup_client.py):_safe_json, client endpoints,create_taskcoercion, session storage lifecycle and TTL eviction, detector trigger parsing, and segment extraction.python3 -S).Preflight Verification
scripts/pr-preflight --lane ci: 16/16 manifest checks passed.clickup-app-client-tests: 37/37 tests passed (0.033s).clickup-app-settings-page-tests: 2/2 tests passed (0.003s).plugin-oauth-client-log-safety-tests: 5/5 tests passed (1.871s).plugins/omi-clickup-app/.Fixes #14267
PayPal: [email protected]
Failure class (fixes)
Failure-Class: none