Skip to content

fix(plugins/omi-stack-overflow-app): handle NoneType in answer owner, support URL question targets, and add test suite #14545

Closed

Description

@shuoYun114

Description

In plugins/omi-stack-overflow-app, several critical edge cases and failure modes lead to unhandled 500 errors and degraded user experience:

  1. Crash on Deleted/Anonymous Users (AttributeError: 'NoneType' object has no attribute 'get'):

    • In _format_answer, the code accessed item.get("owner", {}).get("display_name").
    • When answers are posted by deleted or anonymous users, the Stack Exchange API returns owner: null.
    • Calling .get() on None throws AttributeError: 'NoneType' object has no attribute 'get', causing unhandled 500 error in the chat tool.
  2. Inability to Resolve Question URLs or Conversational IDs:

  3. Dirty Input / Non-finite Coercion:

    • _safe_limit could misbehave when passed NaN, Inf or boolean flags.
    • _safe_tags and _clean_text lacked guards against malformed input payloads and invisible unicode spoofing.
    • _clean_text unescaped HTML before stripping tags, leading to tag-stripping of legitimate code identifiers.
  4. Zero Test Coverage & CI Contract Gap:

    • There was no hermetic unit test suite verifying the endpoints and helper sanitizers.
    • The plugin had no registered test contract in .github/checks-manifest.yaml.

Proposed Solution

  1. Implement defensive _parse_question_target extracting integer question IDs and auto-detecting Stack Exchange network sites from URLs and conversational strings.
  2. Defensively guard _format_answer against owner: null by verifying isinstance(owner, dict).
  3. Correct _clean_text execution order and sanitize limits against boolean and non-finite types.
  4. Add comprehensive hermetic test suite (26 unit tests) running without external dependencies.
  5. Register omi-stack-overflow-tests under .github/checks-manifest.yaml.
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