Skip to content

fix(task-integrations): prevent internal exception text from leaking into HTTP responses and task sync - #18735

Closed
Evos09 wants to merge 2 commits into
BasedHardware:mainfrom
Evos09:fix/task-integrations-exception-leaks
Closed

Evos09 wants to merge 2 commits into
BasedHardware:mainfrom
Evos09:fix/task-integrations-exception-leaks

Conversation

@Evos09

@Evos09 Evos09 commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Remediates sensitive exception leakage across HTTP response and task sync boundaries in backend/routers/task_integrations.py, backend/utils/task_integrations_ops.py, and backend/utils/task_sync.py:

  1. Task Integration Route Handlers (/v1/task-integrations/asana/workspaces, /v1/task-integrations/asana/projects/{workspace_gid}, /v1/task-integrations/clickup/teams, /v1/task-integrations/clickup/spaces/{team_id}, /v1/task-integrations/clickup/lists/{space_id}):

    • Replaced raw exception string interpolation (f"Error fetching ...: {str(e)}") with generic, standardized error messages ("Error fetching workspaces", etc.) returning HTTP 500.
    • Preserves server-side observability using logger.error(f"...: {type(e).__name__}"), avoiding disclosure of raw socket traces, DNS errors, database exceptions, internal file paths, or third-party token details to clients.
  2. Task Integration Operations (utils/task_integrations_ops.py):

    • In refresh_oauth_token, replaced f"Error refreshing token: {str(e)}" and raw logger.error(f'...: {e}') with sanitized exception class logging and generic "Error refreshing token" detail.
    • In create_task_internal, replaced raw {"success": False, "error": str(e)} with sanitized {"success": False, "error": "Failed to create task", "error_code": "internal_error"}.
  3. Task Sync (utils/task_sync.py):

    • In auto_sync_action_item and auto_sync_action_items_batch, replaced raw str(e) in returned sync dictionaries with "Auto-sync failed" and updated server-side logging to record type(e).__name__.
  4. Hermetic Test Suite:

    • Added backend/tests/unit/test_task_integrations_error_sanitization.py verifying that unexpected exceptions, internal traces, database errors, and sensitive server details never leak into HTTP exception details or sync error dictionaries.
    • Tested under standard library unittest: 9/9 tests pass.
    • Registered task-integrations-error-sanitization-tests under .github/checks-manifest.yaml.

Verification

  • python backend/tests/unit/test_task_integrations_error_sanitization.py: 9/9 passing.
  • git diff: Clean, verified diff.

Failure-Class: none

Bounty Payout Destination (EVM - Base Mainnet):
0x7badCdA295Dd7113f374aEA1008e7d5870D48556

Review in cubic

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @Evos09 — this is a genuine hardening improvement, and the pattern (generic client-facing detail plus server-side logger.error(... {type(e).__name__})) matches the convention this codebase already uses elsewhere. I verified statically at the current head that none of the three touched files still reflect raw exception text into HTTPException details or error dicts, and that the remaining detail=f"..." interpolations (e.g. backend/routers/task_integrations.py:356, backend/utils/task_integrations_ops.py:83) only interpolate config values like app_key/name, not exception data. The except HTTPException: raise passthrough is preserved, so 401/404 semantics are unchanged.

Per file:

  • backend/routers/task_integrations.py — all five handlers (asana workspaces/projects, clickup teams/spaces/lists) sanitized consistently.
  • backend/utils/task_integrations_ops.py — refresh_oauth_token and create_task_internal sanitized; the added error_code: "internal_error" gives callers a stable machine-readable signal — good.
  • backend/utils/task_sync.py — both auto_sync_action_item and auto_sync_action_items_batch now return a generic "Auto-sync failed".
  • backend/tests/unit/test_task_integrations_error_sanitization.py — the AST audit test is the strong guard here; the string-assertion tests couple tightly to exact source text (a bit brittle), but acceptable.
  • .github/checks-manifest.yaml — new entry follows the existing id/command/triggers/lanes/reason pattern correctly.

Blocking — CI is red for reasons this PR introduces, and the follow-ups are small:

  1. Formatting: black --check flags the new test file (would reformat backend/tests/unit/test_task_integrations_error_sanitization.py). Running scripts/backend-python-format backend/tests/unit/test_task_integrations_error_sanitization.py should fix it.
  2. Hermetic Backend E2E: testing/e2e/test_task_integrations.py:196 (test_todoist_timeout_returns_failure_without_real_network) still asserts the old contract 'error': 'deterministic Todoist timeout'. Please update it to the sanitized response (and check whether error_code: 'internal_error' now surfaces in that endpoint's payload so the expected dict matches exactly).
  3. Backend unit suite (shard 4): backend/tests/unit/test_task_sync_apple_async_boundary.py:157 (test_apple_reminder_sync_preserves_single_and_batch_error_results) asserts 'error': 'firestore unavailable' for both the single and batch paths — update both expectations to 'Auto-sync failed'.

The Backend Hermetic Merge Gate failure is the e2e failure above aggregated. These existing tests codified the old leaking behavior, so updating them to the sanitized contract is part of this change rather than a workaround. With those three tweaks this should go green — happy to re-review. Leaving for human maintainer review before merge.


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 the backend Backend Task (python) label Sep 25, 2026
@Evos09

Evos09 commented Sep 25, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the detailed review @Git-on-my-level! All three requested updates have been implemented and pushed to the branch:

  1. Formatting: Formatted backend/tests/unit/test_task_integrations_error_sanitization.py with Black.
  2. Hermetic Backend E2E: Updated backend/testing/e2e/test_task_integrations.py:196 expected error assertion from 'deterministic Todoist timeout' to the sanitized contract 'Failed to create task'.
  3. Backend Unit Suite: Updated both single and batch error assertions in backend/tests/unit/test_task_sync_apple_async_boundary.py:157 to 'Auto-sync failed'.

Verified locally that all test suites pass cleanly.

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

origin/main backend/routers/task_integrations.py:468 through :640 return Error fetching … {str(e)}; task_integrations_ops.py:154 and :401 and task_sync.py:52 and :146 return str(e). Tests pin that hole. Required checks are green.

@Evos09

Evos09 commented Sep 25, 2026

Copy link
Copy Markdown
Contributor Author

Thank you @aryanorastar for the review and approval!

@Git-on-my-level Git-on-my-level added the positive-signal Automation verified a genuine fix/quality contribution label Sep 26, 2026
@Git-on-my-level
Git-on-my-level dismissed their stale review September 26, 2026 00:39

Resolved at 62806a2: the new test file passes formatting, the Todoist-timeout e2e assertion (testing/e2e/test_task_integrations.py) now expects the sanitized "Failed to create task" payload, and the apple async-boundary unit test now expects "Auto-sync failed" on both single and batch paths. Full CI is green on this head and a maintainer approval is recorded on it. Dismissing the stale request as resolved — thanks @Evos09.

@Git-on-my-level

Copy link
Copy Markdown
Member

Follow-up verification on the current head, confirming the three updates requested in the earlier automated review are all in place:

  • backend/routers/task_integrations.py — all five 500 handlers (workspaces, projects, teams, spaces, lists) now return generic details with type(e).name logged server-side. I also checked the remaining detail=f"..." interpolations (lines 356, 386, 390, 415): they only interpolate config values like app_key/name, not exception data.
  • backend/utils/task_integrations_ops.py — refresh_oauth_token and the task-creation fallback are sanitized, and the latter now also returns error_code "internal_error", which is a nice touch for clients that branch on codes.
  • backend/utils/task_sync.py — both auto_sync paths return the generic "Auto-sync failed"; backend/tests/unit/test_task_integrations_apple_async_boundary.py expectations match.
  • backend/tests/unit/test_task_integrations_error_sanitization.py — ran the suite standalone (9/9 pass) including the AST structural audit; the .github/checks-manifest.yaml entry wires it into CI correctly.
  • backend/testing/e2e/test_task_integrations.py — updated "Failed to create task" expectation is consistent with the new ops fallback.

One minor non-blocking consistency nit for a possible follow-up: a few server-side-only logger.error calls still interpolate raw {e} (e.g. backend/utils/task_integrations_ops.py:209, backend/routers/task_integrations.py:743/750/764). Those never reach HTTP responses, so they're fine here — just noting the newer type(e).name style reads cleaner in logs too.

Thanks @Evos09 for the quick turnaround on all three items. Already approved by a human maintainer on this head; nothing further needed from my side.


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

@Evos09

Evos09 commented Oct 12, 2026

Copy link
Copy Markdown
Contributor Author

Closing and withdrawing this pull request. Our prior 7 merged contributions totaling $350 (Support Tickets #141289328 / #141291126) remain unpaid by BasedHardware. We are freezing all pending contributions.

@Evos09 Evos09 closed this Oct 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Hey @Evos09 👋

Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request.

After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:

  • Project standards — Ensuring consistency across the codebase
  • User needs — Making sure changes align with what our users need
  • Code best practices — Maintaining code quality and maintainability
  • Project direction — Keeping aligned with our product principles and locked invariants

Before your next PR, please skim:

  • PRODUCT.md — product north star
  • Product invariants — locked rules (shared chat, memory tiers, agent control plane, integrations, brand)

If this was declined for direction or taste, maintainers should cite an invariant ID or open a proposed one — ask if that citation is missing.

Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out.

Thank you for being part of the Omi community!

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

Labels

backend Backend Task (python) positive-signal Automation verified a genuine fix/quality contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants