Skip to content

Fix/malformed UUID in taskiq triggers worker - #6300

Open
oforiwaasam wants to merge 2 commits into
Agenta-AI:mainfrom
oforiwaasam:fix/malformed-uuid-in-taskiq-triggers-worker
Open

Fix/malformed UUID in taskiq triggers worker#6300
oforiwaasam wants to merge 2 commits into
Agenta-AI:mainfrom
oforiwaasam:fix/malformed-uuid-in-taskiq-triggers-worker

Conversation

@oforiwaasam

Copy link
Copy Markdown
Contributor

Summary

dispatch_schedule (the scheduled-trigger worker task) called UUID(project_id) and UUID(str(queued_schedule_id)) with no error handling. A malformed identifier in either field raised an uncaught ValueError, crashing the task outright instead of skipping gracefully. This was inconsistent with every other guard clause in the function, which log and return on bad input rather than raising.

This PR fixes that by wrapping both UUID conversions in a try/except ValueError that logs a warning and returns, matching the existing skip-on-bad-input pattern already used elsewhere in dispatch_schedule (e.g. the missing-identifier and deleted/inactive-schedule checks).

Testing

Verified locally

Ran the targeted test file directly before and after: uv run --no-sync python run-tests.py oss/tests/pytest/unit/triggers/test_triggers_worker_lifecycle.py: 5 tests passed before, 8 passed after (3 new tests added, all green, no regressions in the existing 5). See screenshots below:

Test Results BEFORE changes

Test results logs

image

Generated test report

image

Test Results AFTER changes

image

Generated test report

image

Added or updated tests

Added three tests to oss/tests/pytest/unit/triggers/test_triggers_worker_lifecycle.py:

  • test_schedule_task_skips_when_no_schedule_or_schedule_id_provided — neither schedule_id nor schedule given; asserts the DAO is never queried.
  • test_schedule_task_skips_malformed_project_id — valid schedule_id, malformed project_id; asserts the task returns before the DAO lookup instead of raising.
  • test_schedule_task_skips_malformed_schedule_id — valid project_id, malformed schedule_id; asserts the task returns before the DAO lookup instead of raising.

Linting/Formatting Validation

api % ruff format oss/src/tasks/taskiq/triggers/worker.py oss/tests/pytest/unit/triggers/test_triggers_worker_lifecycle.py
2 files reformatted

QA follow-up

N/A; backend worker fix with unit coverage for all affected branches; no user-facing flow to validate manually.

Demo

N/A

Checklist

  • I have included a video or screen recording for UI changes, or marked Demo as N/A
  • Relevant tests pass locally
  • Relevant linting and formatting pass locally
  • I have signed the CLA, or I will sign it when the bot prompts me

Contributor Resources

Issue

Closes #5935

@vercel

vercel Bot commented Aug 27, 2026

Copy link
Copy Markdown

@oforiwaasam is attempting to deploy a commit to the agenta projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: d5998f6f-07a9-403a-b473-3b75a38dee18

📥 Commits

Reviewing files that changed from the base of the PR and between e24609c and cfc01c4.

📒 Files selected for processing (2)
  • api/oss/src/tasks/taskiq/triggers/worker.py
  • api/oss/tests/pytest/unit/triggers/test_triggers_worker_lifecycle.py

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • Improved scheduled task handling by safely validating project and schedule identifiers.
    • Invalid or missing identifiers now stop dispatch gracefully instead of causing failures.
  • Tests

    • Added coverage for missing and invalid project or schedule identifiers.
    • Verified that no schedule lookup or dispatch occurs when validation fails.

Walkthrough

dispatch_schedule now validates project_id and schedule_id before fetching a schedule. Invalid or missing identifiers cause an early return. Lifecycle tests verify that neither schedule lookup nor dispatch occurs for these inputs.

Changes

Trigger schedule UUID guards

Layer / File(s) Summary
Guard schedule identifier parsing
api/oss/src/tasks/taskiq/triggers/worker.py
dispatch_schedule catches invalid UUID values, logs a warning, and returns before schedule lookup.
Validate skipped dispatch paths
api/oss/tests/pytest/unit/triggers/test_triggers_worker_lifecycle.py
Tests cover missing identifiers, malformed project_id, and malformed schedule_id. Each test verifies that lookup and dispatch are not awaited.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to cfc01

The change safely skips malformed trigger identifiers instead of raising, with targeted tests covering the affected paths; no actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 60.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the malformed UUID handling fix in the Taskiq triggers worker.
Description check ✅ Passed The description directly explains the UUID validation changes, skip behavior, added tests, and validation results.
Linked Issues check ✅ Passed The changes satisfy issue #5935 by guarding project and schedule UUID conversions and adding coverage for missing and malformed identifiers.
Out of Scope Changes check ✅ Passed The changes are limited to the affected worker logic and its focused unit tests. No unrelated code changes are identified.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. python Pull requests that update Python code tests labels Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Pull requests that update Python code size:S This PR changes 10-29 lines, ignoring generated files. tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Taskiq trigger worker: guard UUID conversions and add missing-identifier test coverage

1 participant