Skip to content

feat: handle adlib action validation errors#1643

Merged
imaretic merged 3 commits intoSofie-Automation:mainfrom
evs-broadcast:contribute/log-adlib-action-validation-errors
Apr 8, 2026
Merged

feat: handle adlib action validation errors#1643
imaretic merged 3 commits intoSofie-Automation:mainfrom
evs-broadcast:contribute/log-adlib-action-validation-errors

Conversation

@imaretic
Copy link
Copy Markdown
Contributor

@imaretic imaretic commented Feb 10, 2026

About the Contributor

This PR is posted on behalf of EVS Broadcast Equipment.

Type of Contribution

This is a: Feature

Current Behavior

There is no way for the executeAdlib function to gracefully return payload validation errors and display them to the user if the payload sent by the user is invalid.

New Behavior

The interface of the executeAction function has been extended, and it can now return { validationErrors } or void.

If executeAction returns any validation errors, an error will be thrown, informing the user about the validation issues.

Testing

  • I have added one or more unit tests for this PR
  • I have updated the relevant unit tests
  • No unit test changes are needed for this PR

Affected areas

Interface of executeAction in blueprints-integration package.

Status

  • PR is ready to be reviewed.
  • The functionality has been tested by the author.
  • Relevant unit tests has been added / updated.
  • Relevant documentation (code comments, system documentation) has been added / updated.

@imaretic imaretic added the Contribution from EVS Contributions sponsored by EVS Broadcast Equipment (evs.com) label Feb 10, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 10, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ac6e03e6-35c2-48a7-9407-a2a06857f0b5

📥 Commits

Reviewing files that changed from the base of the PR and between 1a78d40 and 36969cd.

📒 Files selected for processing (3)
  • packages/blueprints-integration/src/api/showStyle.ts
  • packages/corelib/src/worker/studio.ts
  • packages/job-worker/src/playout/adlibAction.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/corelib/src/worker/studio.ts
  • packages/job-worker/src/playout/adlibAction.ts
  • packages/blueprints-integration/src/api/showStyle.ts

Walkthrough

Capture and inspect the return value from blueprint.executeAction; if it contains validationErrors, throw a UserError with UserErrorMessage.ValidationFailed and HTTP status 409. Other post-execution persistence and downstream flows remain unchanged.

Changes

Cohort / File(s) Summary
Adlib action handling
packages/job-worker/src/playout/adlibAction.ts
Capture executeAction result; if result.validationErrors exists, throw UserError (ValidationFailed, 409).
Blueprint API signature
packages/blueprints-integration/src/api/showStyle.ts
ShowStyleBlueprintManifest.executeAction return type changed from Promise<void> to `Promise<{ validationErrors: any }
Worker types
packages/corelib/src/worker/studio.ts
ExecuteActionResult extended with optional validationErrors?: any.

Sequence Diagram(s)

sequenceDiagram
    participant JobWorker as JobWorker (adlibAction)
    participant Blueprint as Blueprint (executeAction)
    participant Corelib as Corelib (state persistence / downstream)

    JobWorker->>Blueprint: executeAction(actionPayload)
    Blueprint-->>JobWorker: return { validationErrors?: any } or void
    alt validationErrors present
        JobWorker->>JobWorker: throw UserError (ValidationFailed, 409)
        JobWorker-->>Client: respond 409 ValidationFailed
    else no validationErrors
        JobWorker->>Corelib: persist state / notify downstream / apply side-effects
        Corelib-->>JobWorker: acknowledgment / continue flow
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • Julusian
🚥 Pre-merge checks | ✅ 2 | ❌ 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 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: handle adlib action validation errors' directly and specifically describes the main change - adding validation error handling to adlib actions.
Description check ✅ Passed The description clearly explains the current behavior, new behavior, affected areas, and testing status, all directly related to the changeset about validation error handling.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 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 and usage tips.

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 10, 2026

Codecov Report

❌ Patch coverage is 42.85714% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
packages/job-worker/src/playout/adlibAction.ts 42.85% 8 Missing ⚠️

📢 Thoughts on this report? Let us know!

@imaretic imaretic marked this pull request as ready for review February 10, 2026 14:28
@imaretic imaretic requested a review from a team as a code owner February 10, 2026 14:28
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/job-worker/src/playout/adlibAction.ts (1)

246-260: ⚠️ Potential issue | 🔴 Critical

Fix the TypeScript compilation error: executeAction returns void, so accessing .validationErrors is invalid.

The blueprint's executeAction method returns Promise<void> (per the blueprint interface in packages/blueprints-integration/src/api/showStyle.ts), making result of type void. Checking result && result.validationErrors triggers TS1345: "An expression of type 'void' cannot be tested for truthiness." The validationErrors property does not exist in any return type—it's not part of ExecuteActionResult.

Remove the validation error check or verify where validation errors are actually surfaced in the action execution flow. If validation errors should be captured, they may be available through the actionContext (as with actionContext.notes on line 275) or require a change to the blueprint interface itself.

@imaretic imaretic marked this pull request as draft February 10, 2026 15:10
@imaretic imaretic force-pushed the contribute/log-adlib-action-validation-errors branch from cc9fdee to e0135c3 Compare February 12, 2026 09:45
@imaretic imaretic changed the title feat: log adlib action validation errors feat: handle adlib action validation errors Feb 12, 2026
@imaretic imaretic marked this pull request as ready for review February 16, 2026 10:33
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/job-worker/src/playout/adlibAction.ts (1)

286-289: ⚠️ Potential issue | 🟡 Minor

validationErrors from blueprint result is not propagated in the return value.

ExecuteActionResult defines an optional validationErrors field, but it is never populated in the return statement (lines 286-289). Instead, validation errors from the blueprint are immediately thrown as exceptions at line 256-260. No caller in the codebase reads validationErrors from the result—they only check the taken field. Either remove the unused field from ExecuteActionResult or populate it to allow callers to handle validation errors without catching exceptions.

🤖 Fix all issues with AI agents
In `@packages/job-worker/src/playout/adlibAction.ts`:
- Around line 256-265: The validation failure check for the AdLib Action should
be moved out of the try/catch so that the UserError thrown by the validation is
not caught and logged as a blueprint execution error; hoist the variable that
receives the blueprint result (e.g., declare let result; before the try),
perform the call that populates result inside the try, then immediately after
the try do the existing if (result && result.validationErrors) { throw
UserError.from(...) } check; ensure the catch still only handles genuine
execution errors from showStyleBlueprint.executeAction so logs remain accurate.
🧹 Nitpick comments (1)
packages/corelib/src/worker/studio.ts (1)

288-288: Consider using a more specific type than any for validationErrors.

Both here and in the ShowStyleBlueprintManifest.executeAction return type, validationErrors is typed as any. A lightweight structured type (e.g., Array<{ path?: string; message: string }> or at least unknown) would improve type safety and make the contract clearer for blueprint implementors and downstream consumers.

That said, userData on line 271 also uses any, so this is consistent with existing conventions in this file.

Comment thread packages/job-worker/src/playout/adlibAction.ts Outdated
@imaretic imaretic marked this pull request as draft February 16, 2026 10:39
@imaretic imaretic force-pushed the contribute/log-adlib-action-validation-errors branch from bd7f1b1 to 7cad592 Compare February 16, 2026 10:59
@imaretic imaretic marked this pull request as ready for review February 16, 2026 11:07
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/corelib/src/worker/studio.ts (1)

285-289: Consider using a more specific type than any for validationErrors.

any bypasses all type checking, making it easy for consumers to misinterpret the shape of validation errors. At minimum, unknown would force callers to narrow the type before use. Ideally, define a concrete type (e.g., Array<{ path: string; message: string }>) that both the blueprint and the worker agree on, so the contract is self-documenting.

This also applies to the matching { validationErrors: any } in showStyle.ts (line 145).

Comment thread packages/blueprints-integration/src/api/showStyle.ts Outdated
@imaretic imaretic merged commit 589d677 into Sofie-Automation:main Apr 8, 2026
23 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Contribution from EVS Contributions sponsored by EVS Broadcast Equipment (evs.com)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants