Skip to content

fix(plugin-workers): derive trigger id from {id} path, fail loudly on missing id (#279)#294

Merged
rickylabs merged 1 commit into
mainfrom
fix/279-triggerjob-path-id
Jul 2, 2026
Merged

fix(plugin-workers): derive trigger id from {id} path, fail loudly on missing id (#279)#294
rickylabs merged 1 commit into
mainfrom
fix/279-triggerjob-path-id

Conversation

@rickylabs

Copy link
Copy Markdown
Owner

Summary

Fixes the one still-open correctness gap from the eis-chat plugin-workers dogfood (#279 Gap 2), extended symmetrically to the sibling triggerTask.

Gap 2 — triggerJob/triggerTask took the id from the request BODY, not the {id} path. The OpenAPI route is POST /jobs/{id}/trigger, but the input schema required id in the body and the created task's id was read from the body — so an empty-body call persisted a task with id=undefined silently (Processing task 'undefined' then Workers KV key contains unsupported part: undefined), leaving the caller with no error. This makes the path {id} the single source of truth and fails loudly when the resolved id is missing.

Change

  • packages/plugin-workers-core/src/contracts/v1/workers.contract-schemas.ts + workers.contract-types.tsid made optional in JobTriggerInputZodSchema and TaskTriggerInputZodSchema (oRPC merges the OpenAPI {id} path param into input.id). Backward compatible: callers that still send a body id round-trip unchanged.
  • plugins/workers/services/src/routers/jobs.ts + tasks.ts — resolve the id from the path and call validationFailed(...) (VALIDATION_ERROR) before any KV write when the id is missing/empty; no path can persist id=undefined.
  • packages/contracts/src/domain/errors.ts + public/mod.ts (+ test) — new centralized validationFailed helper (mirrors the existing notFound; single sanctioned contract-boundary cast, returns never so the id narrows to string).
  • plugins/workers/services/src/trigger-path-id_test.ts — regression for both procedures: empty-body POST resolves the id from the path (never undefined); missing id fails loudly.
  • packages/sdk/tests/integration/workers-trigger-rpc_test.tsGap 1 guard: proves the typed createServiceClient RPC transport reaches triggerJob on a real mounted plugin service (see below).

The other four gaps in #279 were already resolved on main

Triage (grounded on origin/main) found the framework had already landed the fixes for the rest — this PR closes the remainder:

Validation

CI quality trio (fmt/lint/check --unstable-kv) clean over the 4 touched roots; touched tests 6 passed / 0 failed; deno publish --dry-run on plugin-workers-core and contracts both succeed with no --allow-slow-types. Independently reproduced by a separate-session evaluator (PASS). The PR CI runs the scaffold gates (the PR-only scaffold authority).

Fixes #279. Removable eis-chat workaround: the { id: jobId, ... } body-id send in services/eischat/src/jobs.ts (eis-chat PR #83) is no longer needed once this lands.

… missing id (triggerJob + triggerTask) (#279)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012wKHquACkXnWPDgJYhhFjN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant