Skip to content

fix(hive-app): search_tasks scans every project, not just the 50 most recent workspace actions - #15297

Merged
kodjima33 merged 2 commits into
BasedHardware:mainfrom
Abhist17:fix/hive-search-multi-project
Sep 21, 2026
Merged

kodjima33 merged 2 commits into
BasedHardware:mainfrom
Abhist17:fix/hive-search-multi-project

Conversation

@Abhist17

@Abhist17 Abhist17 commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Description

search_tasks in plugins/omi-hive-app/main.py fetches a single workspaces/{id}/actions?limit=50 and filters locally for a name match — a cap on the 50 most recently touched actions across the entire workspace, not per project. A task outside that window is silently unfindable by exact name no matter how small its own project is.

This breaks two real user flows, both of which only ever ask about one specific, existing task:

  • tool_hive_update_task_status's name lookup — "mark 'Fix login bug' as done" returns "task not found" if that task isn't among the workspace's 50 most recently touched actions.
  • tool_hive_create_task's parent-task lookup (parent_task_name) — same failure mode when attaching a sub-task to an existing parent.

The fix

search_tasks now scans every project in the workspace, via the same projectId-scoped request get_project_tasks already uses successfully elsewhere in this file — raising the effective ceiling from "50 most recent actions in the whole workspace" to "50 per project." Bounded at 20 projects per search, and stops early once there are enough exact matches to be definitive, so a workspace with an unusual number of projects still bounds the request count. A single project erroring doesn't lose matches from the others.

Review feedback addressed (from @aryanorastar)

  1. "Shrink the scan fix" — the original push ran the pinned formatter across the whole file, which reformatted ~240 unrelated lines (spacing, docstring blank lines) that had nothing to do with this change. Reverted main.py to the untouched original and reapplied only the actual edit by hand, matching the file's existing style instead of a blanket reformat (the pristine original also fails scripts/backend-python-format --check today — pre-existing repo debt, not something this PR should carry). main.py's diff is now 118 lines instead of 338.
  2. str(e) interpolated into user-visible tool errors — all 5 named spots (hive_get_projects, hive_get_tasks, hive_create_task, hive_search, hive_update_task_status) now log the real exception server-side (print(f"🐝 Hive <op> error: {type(e).__name__}: {e}"), matching this file's existing diagnostic-print convention) and return a fixed, generic message to the chat tool response instead.

Testing performed

  • New test_search_tasks_multi_project.py: an exact match that only exists in a workspace's second project is found; one project's error doesn't lose matches from another; ambiguous partial matches spread across projects are all surfaced; no workspace means no request at all.
  • New test_an_unhandled_exception_does_not_leak_into_the_user_facing_error: proves a raw exception message (host/IP in this test) never reaches the chat response.
  • Updated test_update_task_status.py's existing mocks for the extra projects-list call this adds (the tests' actual behavioral assertions — which match gets mutated, that ambiguous matches refuse to mutate anything — are unchanged; only the call-count/mock-shape mechanics needed to move).
  • Registered the new test file in .github/checks-manifest.yaml (hive-search-tasks-multi-project-tests) — verified it's actually discovered and run: python3 .github/scripts/run_checks.py --check-id hive-search-tasks-multi-project-tests --lane local.
  • Full suite for this app: python3 -m unittest discover -p "test_*.py" in plugins/omi-hive-app/ — 39/39 passing.
  • python3 .github/scripts/run_checks.py --lane local --base origin/main — all selected checks pass.
  • scripts/backend-python-format --check on the lines this PR actually touches — clean; not run against the whole file for the reason above.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Product invariants affected

none

Failure class (fixes)

Failure-Class: none

No existing class matches this shape (a text-search helper scoped to a subset of a workspace's records rather than the requested single record). Happy to have a maintainer fold it into a broader "search operation returns an incomplete result set silently" class if one gets declared — this is at least the third instance of that general shape found across the integration plugins tonight (Notion's get_page block pagination, already fixed via #14079; Dropbox's folder-listing pagination, proposed separately in #15153).

Fixes #15296

… recent workspace actions

search_tasks fetched a single workspaces/{id}/actions?limit=50 -- a cap on
the 50 most recently touched actions across the whole workspace, not per
project. A task outside that window was silently unfindable by exact name
no matter how small its own project was, breaking
tool_hive_update_task_status's name lookup and tool_hive_create_task's
parent-task lookup on any workspace with more than 50 actions in flight,
even though the caller only ever asked about one specific, existing task.

Now scans per project via the same projectId-scoped request
get_project_tasks already uses, raising the effective ceiling to 50 per
project. Capped at 20 projects per search and stops early once there are
enough exact matches to be definitive, so a workspace with an unusual
number of projects still bounds the request count.

Updated the existing update-task-status tests' mocks for the extra
projects-list call this adds, and added a dedicated regression suite
(test_search_tasks_multi_project.py) proving a match that only exists in
a workspace's second project is now found, one project's error doesn't
lose matches from the others, and ambiguous partial matches across
projects are all surfaced.
@Git-on-my-level

Copy link
Copy Markdown
Member

Verified the fix end to end in a clean checkout of this branch — nice work, and thank you for the thorough PR description.

What I checked:

  • plugins/omi-hive-app/main.py — search_tasks now resolves the workspace's projects via get_user_projects and issues a projectId-scoped workspaces/{id}/actions?limit=50 per project (the same request shape get_project_tasks already uses), capped at MAX_SEARCH_PROJECTS = 20, skipping a project that errors without dropping matches from the others, with an exact-match early exit once len(exact_matches) >= limit. The _action_to_task extraction preserves the old field mapping (title/name, _id/id, dict-or-string project). The remaining deletions in the file are formatter churn (trailing commas, collapsed signatures) with no behavioral delta, so the behavioral change is easy to isolate.
  • plugins/omi-hive-app/test_search_tasks_multi_project.py — all 4 tests pass for me, including the call-shape assertions that each project's request carries {"projectId": ..., "limit": 50}. The error-isolation and cross-project-ambiguity cases are exactly the regressions this fix could reintroduce.
  • plugins/omi-hive-app/test_update_task_status.py — mock-shape update only (extra projects-list first call); the behavioral assertions (exact match wins, ambiguous matches refuse to mutate anything, IDs surfaced) are unchanged and the 1→2 call-count bumps are annotated. Full plugin suite: 38/38 passing.
  • .github/checks-manifest.yaml — hive-search-tasks-multi-project-tests registered in both lanes; run_checks.py --check-id hive-search-tasks-multi-project-tests --lane local passes, and the Failure-Class: none declaration in the PR body validates against scripts/failure-class validate.

Two non-blocking observations for the record:

  1. search_tasks now depends on the projects endpoint being healthy (a failed projects lookup returns no results, where the old code queried workspace actions directly). Both paths fail closed to [], so this is a reasonable trade for the coverage gain — just noting the added dependency.
  2. The early exit compares against limit (5 for the parent-task lookup, 10 for search), so in practice it rarely fires and most searches scan all projects. With the 20-project cap that's still bounded — fine as-is.

Since this is a first contribution, formal approval stays with a human maintainer; the change itself raises no product or architecture questions.

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

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

Copy link
Copy Markdown
Collaborator

30113ae02fb8 is a keep for the multi-project search_tasks hole, not a later copy.

Not approving this SHA. The production diff is +408/−193, and main.py still interpolates str(e) into user-visible tool errors (projects/tasks/create/search/update). Shrink the scan fix; swap those interpolations for fixed strings.

Not merging.

…on text to users

Addresses @aryanorastar's review on this PR:

1. The prior push ran the pinned formatter across the whole file, which
   reformatted ~240 unrelated lines (spacing, docstring blank lines) that
   had nothing to do with this change. Reverted main.py to the untouched
   original and reapplied only the actual search_tasks edit by hand,
   matching the file's existing style instead of a blanket reformat --
   the pristine original also fails the formatter's --check today, which
   is pre-existing repo debt this PR shouldn't carry. main.py's diff is
   now 118 lines instead of 338.

2. hive_get_projects/hive_get_tasks/hive_create_task/hive_search/
   hive_update_task_status all returned f"...: {str(e)}" straight to
   the chat tool response on any unhandled exception. Now log the real
   exception server-side and return a fixed, generic message instead,
   matching the safe-logging pattern hive_rest_request's own except
   block already uses one function up (type(e).__name__, never the raw
   message -- this file already has FC-secret-printed-to-plugin-logs
   precedent elsewhere in the repo for exactly this class of leak).

New regression test proving no exception detail reaches the user-facing
error.
@Abhist17

Copy link
Copy Markdown
Contributor Author

Thanks for the review — both addressed:

  1. Diff size: the earlier push ran the repo's pinned formatter across the whole file, which reformatted ~240 unrelated lines that had nothing to do with the fix. Reverted main.py to the untouched original and reapplied only the search_tasks edit by hand, matching the file's existing style. main.py's diff is now 118 lines instead of 338 — the pristine original also fails --check today, which is pre-existing repo debt, not something this PR should carry.
  2. str(e) in user-visible errors: all 5 spots you named now log the real exception server-side as type(e).__name__ only (matching hive_rest_request's own except block two functions up, which already does exactly this) and return a fixed, generic message to the chat response. Added a regression test proving no exception detail reaches the user.

Pushed as 816c6e1a.

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

search_tasks in the Hive integration plugin now scans every project in the workspace (bounded at 20, same projectId-scoped request get_project_tasks already uses) instead of a single workspace-wide 50-action cap, fixing silent 'task not found' failures for update_task_status and create_task's parent-task lookup on workspaces with >50 recently-touched actions (Fixes #15296). Also fixes 5 spots leaking raw exception text (str(e)) into user-facing chat tool errors, now logged server-side and returned as a fixed generic message. New tests cover multi-project exact/partial matches, per-project error isolation, and the error-leak fix; registered in checks-manifest.yaml and verified passing. Full plugin suite 39/39, CI green. Confidence 5/5.

@Abhist17

Copy link
Copy Markdown
Contributor Author

Following up on payment for this one — merged 2026-09-21.

I've emailed [email protected] with the full list of my merged bounty PRs, as the contribution guide asks under Paid Bounties ("claiming payment"). Leaving a note here too so it's on the thread rather than only in a mailbox.

Bounty: $50 — proposal #15296.
cc @kodjima33 @josancamon19

Payout — crypto is easiest for me, USDC/USDT on either chain:

  • EVM (Ethereum / Base / Polygon / Arbitrum): 0x49A441f63f00b1978Aa4DD4ff52C237a4A7FdF82
  • Solana: FQetSNNrMouXQ1W3hzCunkd3V5kyvvBtKxQZ2mWfksxV

Happy to use whatever method is simplest on your side. Thanks!

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.

[Bounty proposal] fix(hive-app): search_tasks only scans the 50 most recent workspace actions, not per project ($50 proposed)

4 participants