Repository navigation
Description
Problem Description
In plugins/zapier/, several edge cases, unbounded HTTP calls, and unhandled exceptions cause runtime crashes or hangs during normal webhook triggering and memory syncing:
-
plugins/zapier/client.py:
•ZapierClient.send_hook_conversation_created,OmiClient.create_conversation, andOmiClient.get_latest_conversationinvokerequests.post()andrequests.get()without atimeoutargument, allowing requests to hang indefinitely on unresponsive webhooks or slow backend endpoints.
•send_hook_conversation_createdchecksresp.status_code != 200to flag errors. Standard Zapier REST hooks frequently respond with HTTP201 Createdor204 No Content, which Omi erroneously logs and treats as failure.
• Deadexcept requests.exceptions.HTTPError:blocks attempt to accessresp.status_codebefore assignment, riskingUnboundLocalError.
•OmiClient.get_latest_conversationassumesresp.json()returns a list and directly accesses index0(resp_json[0]). If upstream returns an error dictionary (e.g.{"detail": "..."}or{"conversations": [...]}), it crashes withKeyError: 0. It also lacks unhandledJSONDecodeErrorprotection on non-JSON proxy responses.
•ZapierDatabasePropertyModel,ZapierDatabaseModel, andZapierOAuthModelcrash on missing keys or non-dict inputs;multi_from_dictiterates over dictionary keys if given a dict. -
plugins/zapier/conversation_created.py:
• In bothget_trigger_conversation_sampleandcreate_zapier_conversation,conversation.structured.emoji.encode('latin1').decode('utf-8')crashes withAttributeError: 'NoneType' object has no attribute 'emoji'ifstructuredisNoneorAttributeErrorifemojiisNone. Furthermore, unhandledUnicodeDecodeErrorcan crash execution if utf-8 decoding fails.
•conversation.transcript_segmentscrashes withTypeErrorifNone, and unshielded lambdas crash if segment items lack thespeakerattribute.
• Subtraction(conversation.finished_at - conversation.started_at)crashes withTypeErrorif either timestamp isNone, and produces negative duration on clock skew.
• Increate_zapier_conversation,sub.decode()crashes withAttributeError: 'str' object has no attribute 'decode'if subscriber URLs in storage or mocks are strings.
• Insubscribe_zapier_triggerandunsubscribe_zapier_trigger, empty or invalid non-HTTP URL schemes are accepted without validation.
• Error responses ungracefully attempt status code lookups without safe integer coercion. -
Zero Unit Test Coverage:
•plugins/zapiercurrently contains no unit tests.
Proposed Solution
- Add
DEFAULT_TIMEOUT = 10.0across all HTTP client calls inplugins/zapier/client.py. - Treat
200 <= resp.status_code < 300as successful webhook execution. - Defensively parse
resp.json()inget_latest_conversationsupporting bare lists, wrapped dicts, and malformed payloads. - Add
_build_zapier_conversation_payloadhelper inplugins/zapier/conversation_created.pywith defensive null guards forstructured,emoji,transcript_segments, and timestamps. - Support both
bytesandstrtypes for subscriber URLs. - Author a 100% hermetic unit test suite (
plugins/zapier/test_zapier_hardening.py) with 17 tests running under standard library Python (python3 -S) in <0.01s with zero third-party dependencies.
Proposed bounty: $50.00 USD.
PayPal: [email protected]
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsIn review
Activity
fix(zapier): harden services with request timeouts, defensive null gu…
chore(ci): fail plugin requests calls that carry no timeout
chore(ci): fail plugin requests calls that carry no timeout
fix(plugins): bound every requests call with a timeout (#15113)