Skip to content

[Plugin] Harden error handling, null guards, and type validation in omi-ms365-app #14247

Closed

Description

@TheRWX

Problem Description

In plugins/omi-ms365-app/services/, several edge cases and unhandled exceptions cause runtime crashes when Microsoft Graph returns null collections, missing fields, or rate-limiting headers:

  1. services/mail.py:

    • read(user_id, message_id) crashes with TypeError: 'NoneType' object is not iterable when Microsoft Graph returns {"toRecipients": null} or {"ccRecipients": null}.
    • read() crashes with KeyError or TypeError if recipient items lack the "emailAddress" dict or are non-dict.
    • list_recent() and search() crash if data.get("value") is None or contains non-dict items; _slim_message() crashes with AttributeError on non-dict input.
    • limit parameter is unbounded.
  2. services/teams.py:

    • list_recent_chats() and list_my_teams() crash with TypeError: 'NoneType' object is not iterable when Graph returns {"value": null}.
    • Unhandled AttributeError if items in value are non-dict.
    • limit parameter is unbounded.
  3. services/sharepoint.py:

    • _slim_item() crashes with TypeError: argument of type 'NoneType' is not iterable on non-dict input due to "folder" in it.
    • list_recent_files() and search_files() crash with TypeError: 'NoneType' object is not iterable if Graph returns {"value": null}.
  4. services/calendar.py:

    • find_free_slots() crashes with TypeError: 'NoneType' object is not iterable when Graph returns {"meetingTimeSuggestions": null}.
    • find_free_slots() crashes with KeyError / TypeError on unshielded nested keys (s["meetingTimeSlot"]["start"]["dateTime"]) if meetingTimeSlot is missing or null.
    • _slim_event() crashes on non-dict input.
  5. services/graph_client.py:

    • int(resp.headers.get("Retry-After", "2")) crashes with ValueError: invalid literal for int() with base 10 when Graph returns an HTTP-date in Retry-After (RFC 7231 / RFC 9110) or non-numeric header on 429/503 responses, killing the request instead of retrying.

Proposed Fixes

  1. Add defensive null and non-dict guards across services/mail.py (_slim_message, list_recent, search, read), safely parsing recipient addresses.
  2. Add defensive null and non-dict guards across services/teams.py (list_recent_chats, list_my_teams, create_online_meeting).
  3. Add defensive dictionary guards across services/sharepoint.py (_slim_item, list_recent_files, search_files, read_file_text).
  4. Add safe nested slot extraction and null guards in services/calendar.py (_slim_event, find_free_slots).
  5. Add _parse_retry_after helper in services/graph_client.py supporting integer seconds and HTTP-date strings.
  6. Author a 100% hermetic unit test suite plugins/omi-ms365-app/test_services_hardening.py running under pure standard library Python (python3 -S) with zero third-party dependencies.

Proposed bounty: $50.00 USD.
PayPal: [email protected]

Activity

  1. moved this from Someday to In progress in omi TODO / bountieson Sep 16, 2026
  2. Evos09 commented on Sep 16, 2026

    @Evos09
    Contributor

    Submitted PR #14252 with a comprehensive hardening fix covering all services in plugins/omi-ms365-app/services/:

    • Defensive null guards and type validation across mail.py, teams.py, sharepoint.py, and calendar.py
    • Clamp bounds (max(1, min(limit, 50))) for list/search operations
    • Robust Retry-After header parsing supporting integer seconds, RFC 7231/9110 HTTP-dates, and invalid fallbacks in graph_client.py
    • 100% hermetic unit test suite in plugins/omi-ms365-app/test_services_hardening.py registered in .github/checks-manifest.yaml (16/16 tests passing under Python stdlib).
  3. moved this from In progress to In review in omi TODO / bountieson Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions