Skip to content

feat(workflow-executor): type-specific PATCH body validation#1508

Merged
Scra3 merged 5 commits intofeat/prd-214-setup-workflow-executor-packagefrom
feat/workflow-executor-patch-body-validation
Mar 25, 2026
Merged

feat(workflow-executor): type-specific PATCH body validation#1508
Scra3 merged 5 commits intofeat/prd-214-setup-workflow-executor-packagefrom
feat/workflow-executor-patch-body-validation

Conversation

@Scra3
Copy link
Copy Markdown
Member

@Scra3 Scra3 commented Mar 25, 2026

Summary

  • Adds per-step-type Zod schemas for PATCH /runs/:runId/steps/:stepIndex/pending-data body validation
  • Adds relatedCollectionName to FieldSchema type
  • Addresses PR review gaps (additional test coverage, fixture cleanups)
  • Uses StepExecutionData cast instead of Parameters utility type

PR 2/3 of the pending-data refactor chain. Depends on #1507.

Test plan

  • Validation tests for each step type (update-record, trigger-action, mcp-task, load-related-record)
  • Unknown/extra field rejection tests
  • yarn workspace @forestadmin/workflow-executor test passes
  • yarn workspace @forestadmin/workflow-executor lint clean

🤖 Generated with Claude Code

Note

Add type-specific Zod validation to the PATCH pending-data endpoint

  • Adds pending-data-validators.ts with strict per-step Zod schemas for update-record, trigger-action, mcp-task, and load-related-record step types.
  • The PATCH /runs/:runId/steps/:stepIndex/pending-data handler in executor-http-server.ts now looks up the step type, selects the matching schema, and returns 400 on validation failure or 404 for unsupported step types.
  • LoadRelatedRecordStepExecutor no longer persists relatedCollectionName in pendingData; instead, it re-derives it from the current collection schema at confirmation time, and fails with an error outcome if the field cannot be resolved.
  • Behavioral Change: PATCH requests with unknown fields or invalid types are now rejected; relatedCollectionName is no longer accepted or stored in load-related-record pending data.

Macroscope summarized 5091231.

@qltysh
Copy link
Copy Markdown

qltysh bot commented Mar 25, 2026

Qlty

Coverage Impact

Unable to calculate total coverage change because base branch coverage was not found.

Modified Files with Diff Coverage (3)

RatingFile% DiffUncovered Line #s
New file Coverage rating: A
...ow-executor/src/executors/load-related-record-step-executor.ts100.0%
New file Coverage rating: A
packages/workflow-executor/src/http/pending-data-validators.ts100.0%
New file Coverage rating: A
packages/workflow-executor/src/http/executor-http-server.ts100.0%
Total100.0%
🚦 See full report on Qlty Cloud »

🛟 Help
  • Diff Coverage: Coverage for added or modified lines of code (excludes deleted files). Learn more.

  • Total Coverage: Coverage for the whole repository, calculated as the sum of all File Coverage. Learn more.

  • File Coverage: Covered Lines divided by Covered Lines plus Missed Lines. (Excludes non-executable lines including blank lines and comments.)

    • Indirect Changes: Changes to File Coverage for files that were not modified in this PR. Learn more.

@Scra3 Scra3 force-pushed the feat/workflow-executor-patch-body-validation branch from 29a5aec to bbda491 Compare March 25, 2026 08:41
Base automatically changed from refactor/workflow-executor-move-user-confirmed-to-pending-data to feat/prd-214-setup-workflow-executor-package March 25, 2026 10:05
@qltysh
Copy link
Copy Markdown

qltysh bot commented Mar 25, 2026

All good ✅

@Scra3 Scra3 force-pushed the feat/workflow-executor-patch-body-validation branch from bbda491 to 4a01bf2 Compare March 25, 2026 10:17
alban bertolini and others added 4 commits March 25, 2026 12:14
…chema relatedCollectionName

- Add `relatedCollectionName` to `FieldSchema` (optional, for relationship fields)
- Extract PATCH body schemas to `src/http/pending-data-validators.ts`
- Replace identical schemas with type-specific ones:
  - `update-record`: accepts optional `value` override
  - `load-related-record`: accepts optional `name`, `displayName`, `selectedRecordId`
  - `trigger-action` / `mcp-task`: `userConfirmed` only
- Fix `resolveFromSelection` (Branch A) to re-derive `relatedCollectionName` from
  FieldSchema instead of stale `pendingData`, so user-overridden relation names work
- Remove `relatedCollectionName` from `LoadRelatedRecordPendingData` (redundant —
  frontend has access to the collection schema)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Fix stale comment on selectedRecordId (PATCH now accepts overrides)
- Add test: relation name override end-to-end (user changes name via PATCH)
- Add test: error message assertion when relatedCollectionName missing from schema
- Add test: mcp-task happy path and extra field rejection
- Add test: hasRunAccess enforced on PATCH route
- Add test: saveStepExecution failure returns 500 on PATCH

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…rameters utility type

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Scra3 Scra3 force-pushed the feat/workflow-executor-patch-body-validation branch from 4a01bf2 to 7758eb7 Compare March 25, 2026 11:16
…lated-record tests

RunStore interface now requires init() and close() after DatabaseStore
merge. The mock factory was missing these methods.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Scra3 Scra3 merged commit 6e7858a into feat/prd-214-setup-workflow-executor-package Mar 25, 2026
30 checks passed
@Scra3 Scra3 deleted the feat/workflow-executor-patch-body-validation branch March 25, 2026 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants