Skip to content

fix(github-app): resolve short repo names, sanitize inputs, and guard null fields - #14224

Merged
kodjima33 merged 1 commit into
BasedHardware:mainfrom
shuoYun114:fix/github-app-repo-disambiguation
Sep 16, 2026
Merged

kodjima33 merged 1 commit into
BasedHardware:mainfrom
shuoYun114:fix/github-app-repo-disambiguation

Conversation

@shuoYun114

@shuoYun114 shuoYun114 commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Closes #14223

Problem & Symptom

  • Voice-driven tool calls passing short repo names (e.g. "in omi") resulted in unmapped single-segment targets passed directly to GitHub endpoints (/repos/omi/issues), resulting in 100% 404 responses.
  • Users with access to multiple repos with the same name across orgs or forks lacked disambiguation, creating ambiguity hazards.
  • github_client.get_issue and list_issues threw TypeError: 'NoneType' object is not iterable whenever GitHub returned explicit null for labels or assignees.
  • Passing non-list labels from LLMs into tool_create_issue caused malformed GitHub payload construction and 422 Unprocessable Entity responses.
  • Tool callers invoking /tools/add_issue_comment received 404 because only /tools/add_comment was registered.
  • URL parsing was susceptible to spoofed userinfo domains, failed on single-segment paths, and rejected standard [email protected]: SSH format.
  • save_users() wrote directly to disk without locks or atomic replace, risking zero-byte corruption under concurrency.

Solution & Changes

  • main.py:
    • Implemented _validate_owner_repo and get_repo_for_request using ^[a-zA-Z0-9_.-]+$ whitelist regex, blocking control chars (\n, \r, \t, \0) and traversal (., ..).
    • Added short-name resolution against available_repos and selected_repo with unambiguous match resolution, explicit candidate disambiguation errors, and substring matching threshold (len >= 3).
    • Hardened URL handling with urllib.parse.urlparse checking hostname, blocking spoofed hosts, and handling SSH URLs.
    • Normalized labels in tool_create_issue to handle string lists or None.
    • Added @app.post("/tools/add_issue_comment") route alias for full compatibility.
    • Validated repository updates in /update-repo.
  • github_client.py:
    • Replaced unsafe dict.get(..., []) iteration with null-safe comprehension guards (issue.get("labels") or []) checking item dict structures.
    • Replaced non-ASCII log emojis (❌, ⚠️) with [ERROR] and [WARN] to prevent Windows/ASCII stdout encoding crashes.
    • Added explicit timeout=self.timeout across all network requests.
  • simple_storage.py:
    • Implemented threading.Lock and atomic write (tempfile + os.replace) in save_users().
  • .github/checks-manifest.yaml & test_main.py:
    • Expanded test suite to 73 pure standard-library hermetic unit tests covering resolution, injection defenses, null resilience, and endpoint contracts.
    • All 52 manifest check tests passing cleanly.

Verification

$ python plugins/omi-github-app/test_main.py
Ran 73 tests in 0.023s - OK

$ python -m unittest plugins/omi-github-app/test_github_client.py
Ran 10 tests in 0.003s - OK

$ python .github/scripts/test_run_checks.py
Ran 52 tests in 4.859s - OK (skipped=1)

Bounty & Contributor Reward Proposal

US$50 Bounty + 1-PR Contributor DevKit Reward (@josancamon19 @kodjima33):

  • Bitcoin (BTC): 1NkUnv23H65ZYJn64pseAcWRA6sJitxh2f (Network: Bitcoin Mainnet)
  • Contact Email: [email protected]
  • Contributor Reward: Omi DevKit Device (Necklace / Glasses) under official Omi Contribution Guidelines.

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Backend plugin bug fix (confidence 4/5: root cause stated, closes #14223, CI green, 73 tests added; diff size is the only miss). Confirmed not already fixed on main (prior #14080 addressed a different issue).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(omi-github-app): resolve short repo names, sanitize inputs, and prevent null field crashes

3 participants