Skip to content

fix(omi-slack-app): resolve channel targets, link formats, and guard untyped inputs in chat tools - #14693

Merged
aryanorastar merged 1 commit into
BasedHardware:mainfrom
TheRWX:fix/slack-channel-resolution
Sep 22, 2026
Merged

aryanorastar merged 1 commit into
BasedHardware:mainfrom
TheRWX:fix/slack-channel-resolution

Conversation

@TheRWX

@TheRWX TheRWX commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

fix(omi-slack-app): resolve channel targets, link formats, and guard untyped inputs in chat tools

Chat-tool inputs in plugins/omi-slack-app arrived loosely typed or in standard Slack mention/link syntax (<#C012345678|general>, <#C012345678>, archive URLs), and unvalidated non-string parameters crashed handlers with 500 AttributeErrors:

  • POST /api/send_message strictly matched ch["name"] == channel.lstrip('#'), failing every raw channel ID (e.g. C012345678) or mention format even when valid in the workspace.
  • Non-string or null channel in send_message and search_messages crashed on channel.lstrip('#') with AttributeError, returning HTTP 500.
  • Non-string query in search_messages and search_channels crashed on query.lower() with AttributeError, returning HTTP 500.
  • Raw channel mentions <#C...> in search_messages failed to match startswith(('C', 'G')), dropping to workspace search rejections.

Changes:

  • Added parse_channel_target and resolve_channel_id in slack_client.py to extract and resolve channel IDs across raw IDs (C..., G..., D...), mention syntax (<#ID|name>, <#ID>), archive URLs, and channel names.
  • Wired channel resolution and strict request parameter type validation into chat_tool_send_message, chat_tool_search_messages, and chat_tool_search_channels.
  • Added hermetic regression suite plugins/omi-slack-app/test_slack_chat_tools.py and registered in .github/checks-manifest.yaml.

Verification:

  • python3 plugins/omi-slack-app/test_slack_chat_tools.py: 11 tests pass
  • python3 plugins/omi-slack-app/test_slack_search.py: 5 tests pass
  • python3 plugins/omi-slack-app/test_channel_resolution.py: 9 tests pass
  • python3 plugins/omi-slack-app/test_segments.py: 8 tests pass

Failure-Class: FC-chat-tool-input-assumed-typed-and-complete
PayPal: [email protected]

Review in cubic

@Git-on-my-level

Copy link
Copy Markdown
Member

Verified end to end — thanks for the tight failure class and the hermetic coverage.

What I checked:

  • plugins/omi-slack-app/slack_client.py — parse_channel_target() handles <#C123|general>, <#C123>, archive URLs, #name, and bare C/G/D... IDs with a plain-name fallback; resolve_channel_id() then prefers exact ID/name matches against the workspace listing. Importantly it keeps the guarantees from the earlier fuzzy-match fix: search_messages() still refuses with channel_not_found_or_unavailable instead of degrading to a workspace-wide search when a named channel doesn't resolve, and name matching stays exact-only. search_channels() also keeps substring matching for plain-name queries while adding mention/ID syntax.
  • plugins/omi-slack-app/main.py — all three chat-tool endpoints now return 400 on non-dict bodies and non-string/blank uid/channel/message/query instead of crashing with AttributeError 500s; channel lookup collapses to a single resolve_channel_id() call; and the success message no longer doubles the # prefix when the caller passed a mention like <#C123|general>.
  • plugins/omi-slack-app/test_slack_chat_tools.py — 11 hermetic tests covering raw IDs, both mention forms, archive URLs, and the non-string-parameter 400s, with all import boundaries (fastapi, slack_sdk, simple_storage, message_detector) stubbed so nothing touches live Slack or user storage.
  • .github/checks-manifest.yaml — the new slack-chat-tools-tests entry (python3 plugins/omi-slack-app/test_slack_chat_tools.py, local+ci lanes) matches the shape of the adjacent entries.

I also ran all four plugin suites against this head in an isolated container: test_slack_chat_tools.py (11), test_slack_search.py (5), test_channel_resolution.py (9), and test_segments.py (8) — 33/33 pass.

One minor edge, non-blocking: in parse_channel_target(), a workspace channel literally named like a raw ID (e.g. C123) is parsed as an ID, and the mention/archive regexes match anywhere in the string, so a value like see <#C123|general> resolves to that mention. Same net behavior as the old startswith('C'/'G') branch for current callers, but worth knowing if inputs ever get messier.

Clean fix on top of the earlier channel-resolution work, and the regression suite locks the contract in.

  • automated maintainer review on behalf of the Omi maintainers; human sign-off applies before merge (two Desktop Swift checks still running)

by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level Git-on-my-level added python positive-signal Automation verified a genuine fix/quality contribution labels Sep 19, 2026

@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.

Good scoped channel-resolution/validation hardening reusing existing helper; DIRTY (conflict) and unrelated Desktop Swift CI failure (rerun triggered) - approve only.

@TheRWX
TheRWX force-pushed the fix/slack-channel-resolution branch 2 times, most recently from 42b48d1 to c3a41dd Compare September 19, 2026 15:49
@Git-on-my-level

Copy link
Copy Markdown
Member

Verified end to end against the current head: all four registered omi-slack-app suites pass locally (33 tests, hermetic, no network) — including the new one and the pre-existing explicit-channel-search and channel-resolution regression suites whose contracts this change rewrites.

  • plugins/omi-slack-app/slack_client.py — parse_channel_target/resolve_channel_id cleanly replace the three ad-hoc name-matching loops; name matching stays exact (case-insensitive), so there's no fuzzy drift (the fuzzy spoken-name resolver resolve_channel is untouched and its suite still passes). One design note, not a blocker: an unmatched C/G/D-shaped ID now passes through to the Slack API rather than 400-ing early. That mirrors the old startswith('C'/'G') behavior in search_messages, and Slack enforces the real authorization against the user's token, so it seems fine — just calling it out because chat_tool_send_message now shares that behavior.
  • plugins/omi-slack-app/main.py — the isinstance/strip guards on uid/channel/message turn the previous AttributeError 500s into 400s, and the optional-channel handling in chat_tool_search_messages (None allowed, non-string/blank rejected) is the right split. Non-blocking nit: the try/except ImportError fallback around from slack_client import resolve_channel_id can't trigger in-tree since slack_client.py always defines the function, and the fallback body only works via sys.modules indirection — a plain import would be simpler in a follow-up.
  • plugins/omi-slack-app/test_slack_chat_tools.py — genuinely hermetic (fastapi/slack_sdk/storage stubbed; runs in ~0.05s) and it asserts the real contract: chat_postMessage called with the resolved channel ID, and 400-not-500 for non-string/blank inputs. Good coverage of mention syntax, bare IDs, and archive URLs.
  • .github/checks-manifest.yaml — slack-chat-tools-tests matches the sibling entries' shape (direct python3 invocation, plugin + manifest triggers, local/ci lanes), and Hygiene plus the Backend Hermetic Merge Gate pass with it registered.

Thanks @TheRWX — this removes a real class of agent-facing 500s and makes channel targeting behave the way the chat tools advertise. One FYI for maintainers: the approval on record predates the current head commit (the branch was updated after it), so the head may deserve a quick re-glance before merge.

🤖 Automated review on behalf of the maintainers.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@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.

fix(omi-slack-app): confidence ~4/5 - detailed root cause per bullet, concrete fix(...) title, CI green, hermetic regression suite added; diff is 415 lines (over the 300 soft cap) across 4 files. NOT merging: mergeStateStatus is UNKNOWN (stale/recomputing) -- per prior guidance, do not merge on UNKNOWN.

@aryanorastar aryanorastar 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.

Verified on c3a41dd465c2.

Slack chat tools resolve channel targets from link formats and guard untyped inputs. I ran plugins/omi-slack-app/test_slack_chat_tools.py against this tip: 11/11 OK.

kodjima APPROVE is not a merge. I am not merging.

@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.

Genuine bug fix: guards untyped chat-tool inputs and resolves Slack channel mentions/IDs/URLs that previously 500'd or failed to match. Scoped core change (~135 lines) with a 225-line hermetic regression suite (11 tests) plus existing suites all passing. CI fully green. Confidence 5/5.

…untyped inputs in chat tools

Chat-tool inputs in plugins/omi-slack-app arrived loosely typed or in standard Slack mention/link syntax (<#C012345678|general>, <#C012345678>, archive URLs), and unvalidated non-string parameters crashed handlers with 500 AttributeErrors:
- POST /api/send_message strictly matched ch['name'] == channel.lstrip('#'), failing every raw channel ID (e.g. C012345678) or mention format even when valid in the workspace.
- Non-string or null channel in send_message and search_messages crashed on channel.lstrip('#') with AttributeError, returning HTTP 500.
- Non-string query in search_messages and search_channels crashed on query.lower() with AttributeError, returning HTTP 500.
- Raw channel mentions <#C...> in search_messages failed to match startswith(('C', 'G')), dropping to workspace search rejections.

Changes:
- Added parse_channel_target and resolve_channel_id in slack_client.py to extract and resolve channel IDs across raw IDs (C..., G..., D...), mention syntax (<#ID|name>, <#ID>), archive URLs, and channel names.
- Wired channel resolution and strict request parameter type validation into chat_tool_send_message, chat_tool_search_messages, and chat_tool_search_channels.
- Added hermetic regression suite plugins/omi-slack-app/test_slack_chat_tools.py and registered in .github/checks-manifest.yaml.

Failure-Class: FC-chat-tool-input-assumed-typed-and-complete
@TheRWX
TheRWX force-pushed the fix/slack-channel-resolution branch from c3a41dd to 6e4b1f9 Compare September 21, 2026 15:48
@TheRWX

TheRWX commented Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto 013e2ae8a99a in 6e4b1f9f62. The approved implementation is unchanged; the manifest conflict now retains both the upstream error-handling suite and this PR's chat-tool suite. All 54 Slack plugin tests and all 20 selected native preflight checks pass. GitHub now reports the branch mergeable.

PayPal: [email protected]

@aryanorastar aryanorastar 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.

Re-reviewed current head 6e4b1f9f62bf (prior APPROVE was c3a41dd465c2). parse_channel_target / resolve_channel_id are still absent on origin/main. Tests pin channel-link and untyped-input guards. Hygiene SUCCESS. Not merging.

@aryanorastar
aryanorastar merged commit fb4fd69 into BasedHardware:main Sep 22, 2026
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

positive-signal Automation verified a genuine fix/quality contribution python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants