Skip to content

feat: replace meteor/check with a zod based validator - #1803

Merged
Julusian merged 1 commit into
Sofie-Automation:mainfrom
SuperFlyTV:feat/replace-meteor-check
Aug 17, 2026
Merged

feat: replace meteor/check with a zod based validator#1803
Julusian merged 1 commit into
Sofie-Automation:mainfrom
SuperFlyTV:feat/replace-meteor-check

Conversation

@Julusian

Copy link
Copy Markdown
Member

About the Contributor

Type of Contribution

This is a: Feature / Code improvement

This is part of a series of PRs aiming to replace meteor.

This builds upon #1785, as it conflicts heavily with the refactoring there

Current Behavior

For ddp methods, we are using 'meteor/check' to validate method arguments. As part of removing our usage of meteor, this will need to be replaced.

New Behavior

Instead of porting the meteor code, or building something new, I decided to try out zod for this. The usage and DX could be better, but I see that as a follow up.

For now this is a fairly minimal port of existing semantics, but using zod for the validation.

In the future, I would like to see us rework the method definition process to include providing a zod schema so that we can be sure the validation is performed correctly, and matches the types (as the types will be inferred from the schema)

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

Time Frame

Other Information

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.

@Julusian Julusian added the Contribution from SuperFly.tv Contributions sponsored by SuperFly.tv label Jul 29, 2026
@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@Julusian, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 12 minutes

Limit details: You’ve used all 2 included reviews currently available under your plan.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3fea4ca2-cf7f-4ba1-a98d-0e8d5a3b6dd4

📥 Commits

Reviewing files that changed from the base of the PR and between 1b42ccf and a27190d.

⛔ Files ignored due to path filters (1)
  • meteor/yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (6)
  • meteor/__mocks__/_setupMocks.ts
  • meteor/package.json
  • meteor/server/api/blueprints/__tests__/api.test.ts
  • meteor/server/lib/__tests__/check.test.ts
  • meteor/server/lib/check.ts
  • meteor/server/publicationRegistry.ts

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c7a99129-a870-4005-b628-87fe5c69ea81

📥 Commits

Reviewing files that changed from the base of the PR and between 2a33035 and 1b42ccf.

⛔ Files ignored due to path filters (1)
  • meteor/yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (66)
  • meteor/.meteor/versions
  • meteor/__mocks__/_setupMocks.ts
  • meteor/__mocks__/check/README
  • meteor/__mocks__/check/index.ts
  • meteor/__mocks__/check/isPlainObject.js
  • meteor/__mocks__/check/match.js
  • meteor/package.json
  • meteor/server/api/ExternalMessageQueue.ts
  • meteor/server/api/blueprints/__tests__/api.test.ts
  • meteor/server/api/blueprints/api.ts
  • meteor/server/api/blueprints/http.ts
  • meteor/server/api/client.ts
  • meteor/server/api/deviceTriggers/observer.ts
  • meteor/server/api/ingest/debug.ts
  • meteor/server/api/ingest/http.ts
  • meteor/server/api/ingest/rundownInput.ts
  • meteor/server/api/integration/expectedPackages.ts
  • meteor/server/api/peripheralDevice.ts
  • meteor/server/api/playout/debug.ts
  • meteor/server/api/rest/v1/blueprints.ts
  • meteor/server/api/rest/v1/buckets.ts
  • meteor/server/api/rest/v1/devices.ts
  • meteor/server/api/rest/v1/ingest.ts
  • meteor/server/api/rest/v1/playlists.ts
  • meteor/server/api/rest/v1/showstyles.ts
  • meteor/server/api/rest/v1/snapshots.ts
  • meteor/server/api/rest/v1/studios.ts
  • meteor/server/api/rest/v1/system.ts
  • meteor/server/api/rundown.ts
  • meteor/server/api/rundownLayouts.ts
  • meteor/server/api/showStyles.ts
  • meteor/server/api/snapshot.ts
  • meteor/server/api/studio/api.ts
  • meteor/server/api/system.ts
  • meteor/server/api/triggeredActions.ts
  • meteor/server/api/userActions.ts
  • meteor/server/lib/__tests__/check.test.ts
  • meteor/server/lib/check.ts
  • meteor/server/methodRegistry.ts
  • meteor/server/migration/api.ts
  • meteor/server/publicationRegistry.ts
  • meteor/server/publications/buckets.ts
  • meteor/server/publications/deviceTriggersPreview.ts
  • meteor/server/publications/externalEventSubscriptions.ts
  • meteor/server/publications/ingestStatus/publication.ts
  • meteor/server/publications/mountedTriggers.ts
  • meteor/server/publications/organization.ts
  • meteor/server/publications/packageManager/expectedPackages/publication.ts
  • meteor/server/publications/packageManager/packageContainers.ts
  • meteor/server/publications/packageManager/playoutContext.ts
  • meteor/server/publications/partInstancesUI/publication.ts
  • meteor/server/publications/partsUI/publication.ts
  • meteor/server/publications/peripheralDevice.ts
  • meteor/server/publications/peripheralDeviceForDevice.ts
  • meteor/server/publications/pieceContentStatusUI/bucket/publication.ts
  • meteor/server/publications/pieceContentStatusUI/rundown/publication.ts
  • meteor/server/publications/rundown.ts
  • meteor/server/publications/rundownPlaylist.ts
  • meteor/server/publications/segmentPartNotesUI/publication.ts
  • meteor/server/publications/showStyle.ts
  • meteor/server/publications/showStyleUI.ts
  • meteor/server/publications/studio.ts
  • meteor/server/publications/studioUI.ts
  • meteor/server/publications/system.ts
  • meteor/server/publications/timeline.ts
  • meteor/server/publications/triggeredActionsUI.ts
💤 Files with no reviewable changes (6)
  • meteor/mocks/check/match.js
  • meteor/.meteor/versions
  • meteor/mocks/check/README
  • meteor/mocks/check/index.ts
  • meteor/mocks/check/isPlainObject.js
  • meteor/mocks/_setupMocks.ts
🚧 Files skipped from review as they are similar to previous changes (45)
  • meteor/package.json
  • meteor/server/publications/deviceTriggersPreview.ts
  • meteor/server/api/rest/v1/blueprints.ts
  • meteor/server/publications/peripheralDevice.ts
  • meteor/server/api/rest/v1/snapshots.ts
  • meteor/server/api/rest/v1/devices.ts
  • meteor/server/api/blueprints/http.ts
  • meteor/server/api/deviceTriggers/observer.ts
  • meteor/server/methodRegistry.ts
  • meteor/server/publications/packageManager/playoutContext.ts
  • meteor/server/api/ingest/http.ts
  • meteor/server/api/ingest/debug.ts
  • meteor/server/publications/buckets.ts
  • meteor/server/api/rest/v1/system.ts
  • meteor/server/publications/packageManager/expectedPackages/publication.ts
  • meteor/server/publications/ingestStatus/publication.ts
  • meteor/server/publications/pieceContentStatusUI/bucket/publication.ts
  • meteor/server/publications/rundownPlaylist.ts
  • meteor/server/lib/tests/check.test.ts
  • meteor/server/publicationRegistry.ts
  • meteor/server/publications/mountedTriggers.ts
  • meteor/server/publications/peripheralDeviceForDevice.ts
  • meteor/server/publications/triggeredActionsUI.ts
  • meteor/server/api/rest/v1/studios.ts
  • meteor/server/publications/partInstancesUI/publication.ts
  • meteor/server/publications/studioUI.ts
  • meteor/server/lib/check.ts
  • meteor/server/api/rest/v1/buckets.ts
  • meteor/server/publications/studio.ts
  • meteor/server/api/ingest/rundownInput.ts
  • meteor/server/api/integration/expectedPackages.ts
  • meteor/server/api/rest/v1/showstyles.ts
  • meteor/server/migration/api.ts
  • meteor/server/publications/showStyleUI.ts
  • meteor/server/publications/partsUI/publication.ts
  • meteor/server/publications/organization.ts
  • meteor/server/api/ExternalMessageQueue.ts
  • meteor/server/api/rest/v1/playlists.ts
  • meteor/server/api/rest/v1/ingest.ts
  • meteor/server/api/triggeredActions.ts
  • meteor/server/publications/system.ts
  • meteor/server/api/rundownLayouts.ts
  • meteor/server/publications/rundown.ts
  • meteor/server/publications/timeline.ts
  • meteor/server/api/userActions.ts

Included review availability: Your plan includes up to 2 reviews per rolling hour; 0 remain after this review.


Walkthrough

This change replaces Meteor check and Match validation with Zod schemas and local helpers. It adds explicit API and publication registration functions, updates affected server and REST modules, removes obsolete mocks, and adds Zod validation tests.

Changes

Zod validation foundation

Layer / File(s) Summary
Shared validation and test coverage
meteor/server/lib/check.ts, meteor/server/lib/__tests__/check.test.ts
check() now validates Zod schemas and throws formatted SofieError responses. Shared plain-object and array schemas were added. Tests cover nullish values, strict objects, error paths, client-safe errors, and disabled checks.

Server API and REST migration

Layer / File(s) Summary
Server API validation and exports
meteor/server/api/..., meteor/server/migration/api.ts, meteor/server/methodRegistry.ts
Server API methods now use Zod validators. ServerExternalMessageQueueAPI and ServerUserActionAPI are exported with explicit return types. Method-registry follow-up documentation was added.
REST endpoint validation
meteor/server/api/rest/v1/...
REST handlers now use Zod string, number, boolean, array, union, and plain-object schemas. Endpoint paths and core operations remain unchanged.

Publication registration

Layer / File(s) Summary
Explicit publication registration
meteor/server/publications/...
Publication modules now expose registry-based registration functions where required. Existing authorization, observers, selectors, cursors, and publication data handling remain in place.
Publication invalidation behavior
meteor/server/publications/partsUI/publication.ts
Removal invalidation handlers were removed. Additions and changes remain invalidating, and part rank changes invalidate the full segment.

Supporting setup

Layer / File(s) Summary
Dependency and test setup
meteor/package.json, meteor/__mocks__/_setupMocks.ts, meteor/server/api/blueprints/__tests__/api.test.ts
Zod was added as a runtime dependency. The virtual meteor/check mock was removed. A blueprint validation error expectation was updated.

Estimated code review effort: 4 (Complex) | ~45 minutes

Merge Risk: ⚪ Minimal · up to 1b42c

This validation replacement is merge-ready after normal checks and review; no actionable merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.90% which is insufficient. The required threshold is 80.00%. 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 summarizes the main change: replacing meteor/check validation with a Zod-based validator.
Description check ✅ Passed The description directly explains the migration from meteor/check to Zod and its purpose within the broader Meteor removal effort.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ 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.

@Julusian
Julusian marked this pull request as ready for review July 29, 2026 16:04

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
meteor/server/api/system.ts (1)

391-394: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

cleanupIndexes return type left as any unlike its siblings.

The other three methods added in this same pass (cleanupOldData, runCronjob, doSystemBenchmark) got precise return types, but cleanupIndexes is typed Promise<any> even though the underlying function returns Promise<Array<IndexSpecification>>. This forfeits the type-safety this change was meant to add for this one method.

♻️ Proposed fix
-	async cleanupIndexes(actuallyRemoveOldIndexes: boolean): Promise<any> {
+	async cleanupIndexes(actuallyRemoveOldIndexes: boolean): Promise<Array<IndexSpecification>> {
 		return cleanupIndexes(this, actuallyRemoveOldIndexes)
 	}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@meteor/server/api/system.ts` around lines 391 - 394, Update
SystemAPIClass.cleanupIndexes to return Promise<Array<IndexSpecification>>
instead of Promise<any>, matching the return type of the delegated
cleanupIndexes function and the precise typing used by its sibling methods.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@meteor/server/api/system.ts`:
- Around line 391-394: Update SystemAPIClass.cleanupIndexes to return
Promise<Array<IndexSpecification>> instead of Promise<any>, matching the return
type of the delegated cleanupIndexes function and the precise typing used by its
sibling methods.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c00f215a-a9d3-47a1-8b60-68f8d233f6af

📥 Commits

Reviewing files that changed from the base of the PR and between 4169002 and 322cf80.

⛔ Files ignored due to path filters (3)
  • meteor/server/__tests__/__snapshots__/methodRegistry.test.ts.snap is excluded by !**/*.snap
  • meteor/server/__tests__/__snapshots__/publicationRegistry.test.ts.snap is excluded by !**/*.snap
  • meteor/yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (99)
  • meteor/.meteor/versions
  • meteor/__mocks__/_setupMocks.ts
  • meteor/__mocks__/check/README
  • meteor/__mocks__/check/index.ts
  • meteor/__mocks__/check/isPlainObject.js
  • meteor/__mocks__/check/match.js
  • meteor/__mocks__/helpers/methods.ts
  • meteor/__mocks__/helpers/publications.ts
  • meteor/package.json
  • meteor/server/__tests__/cronjobs.test.ts
  • meteor/server/__tests__/methodRegistry.test.ts
  • meteor/server/__tests__/publicationRegistry.test.ts
  • meteor/server/api/ExternalMessageQueue.ts
  • meteor/server/api/__tests__/client.test.ts
  • meteor/server/api/__tests__/externalMessageQueue.test.ts
  • meteor/server/api/__tests__/peripheralDevice.test.ts
  • meteor/server/api/__tests__/rundownLayouts.test.ts
  • meteor/server/api/__tests__/userActions/general.test.ts
  • meteor/server/api/__tests__/userActions/system.test.ts
  • meteor/server/api/blueprints/__tests__/api.test.ts
  • meteor/server/api/blueprints/api.ts
  • meteor/server/api/blueprints/http.ts
  • meteor/server/api/client.ts
  • meteor/server/api/deviceTriggers/observer.ts
  • meteor/server/api/ingest/debug.ts
  • meteor/server/api/ingest/http.ts
  • meteor/server/api/ingest/rundownInput.ts
  • meteor/server/api/integration/expectedPackages.ts
  • meteor/server/api/mongo.ts
  • meteor/server/api/peripheralDevice.ts
  • meteor/server/api/playout/api.ts
  • meteor/server/api/playout/debug.ts
  • meteor/server/api/rest/api.ts
  • meteor/server/api/rest/v0/__tests__/rest.test.ts
  • meteor/server/api/rest/v0/index.ts
  • meteor/server/api/rest/v1/blueprints.ts
  • meteor/server/api/rest/v1/buckets.ts
  • meteor/server/api/rest/v1/devices.ts
  • meteor/server/api/rest/v1/ingest.ts
  • meteor/server/api/rest/v1/playlists.ts
  • meteor/server/api/rest/v1/showstyles.ts
  • meteor/server/api/rest/v1/snapshots.ts
  • meteor/server/api/rest/v1/studios.ts
  • meteor/server/api/rest/v1/system.ts
  • meteor/server/api/rundown.ts
  • meteor/server/api/rundownLayouts.ts
  • meteor/server/api/showStyles.ts
  • meteor/server/api/snapshot.ts
  • meteor/server/api/studio/api.ts
  • meteor/server/api/system.ts
  • meteor/server/api/triggeredActions.ts
  • meteor/server/api/user.ts
  • meteor/server/api/userActions.ts
  • meteor/server/lib/__tests__/check.test.ts
  • meteor/server/lib/check.ts
  • meteor/server/lib/customPublication/index.ts
  • meteor/server/lib/customPublication/publish.ts
  • meteor/server/main.ts
  • meteor/server/methodRegistrations.ts
  • meteor/server/methodRegistry.ts
  • meteor/server/methods.ts
  • meteor/server/migration/__tests__/migrations.test.ts
  • meteor/server/migration/api.ts
  • meteor/server/publicationRegistrations.ts
  • meteor/server/publicationRegistry.ts
  • meteor/server/publications/_publications.ts
  • meteor/server/publications/blueprintUpgradeStatus/publication.ts
  • meteor/server/publications/buckets.ts
  • meteor/server/publications/deviceTriggersPreview.ts
  • meteor/server/publications/externalEventSubscriptions.ts
  • meteor/server/publications/ingestStatus/publication.ts
  • meteor/server/publications/lib/lib.ts
  • meteor/server/publications/mountedTriggers.ts
  • meteor/server/publications/organization.ts
  • meteor/server/publications/packageManager/expectedPackages/publication.ts
  • meteor/server/publications/packageManager/packageContainers.ts
  • meteor/server/publications/packageManager/playoutContext.ts
  • meteor/server/publications/partInstancesUI/publication.ts
  • meteor/server/publications/partsUI/publication.ts
  • meteor/server/publications/peripheralDevice.ts
  • meteor/server/publications/peripheralDeviceForDevice.ts
  • meteor/server/publications/pieceContentStatusUI/bucket/publication.ts
  • meteor/server/publications/pieceContentStatusUI/rundown/publication.ts
  • meteor/server/publications/rundown.ts
  • meteor/server/publications/rundownPlaylist.ts
  • meteor/server/publications/segmentPartNotesUI/publication.ts
  • meteor/server/publications/showStyle.ts
  • meteor/server/publications/showStyleUI.ts
  • meteor/server/publications/studio.ts
  • meteor/server/publications/studioUI.ts
  • meteor/server/publications/system.ts
  • meteor/server/publications/timeline.ts
  • meteor/server/publications/translationsBundles.ts
  • meteor/server/publications/triggeredActionsUI.ts
  • meteor/server/security/check.ts
  • meteor/server/security/securityVerify.ts
  • meteor/server/systemStatus/__tests__/api.test.ts
  • meteor/server/systemStatus/__tests__/systemStatus.test.ts
  • meteor/server/systemStatus/api.ts
💤 Files with no reviewable changes (7)
  • meteor/mocks/check/index.ts
  • meteor/mocks/check/README
  • meteor/mocks/check/isPlainObject.js
  • meteor/mocks/_setupMocks.ts
  • meteor/mocks/check/match.js
  • meteor/server/publications/_publications.ts
  • meteor/.meteor/versions

@Julusian
Julusian force-pushed the feat/replace-meteor-check branch from 322cf80 to 1b42ccf Compare August 17, 2026 09:07
@coderabbitai

coderabbitai Bot commented Aug 17, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@Julusian
Julusian force-pushed the feat/replace-meteor-check branch from 1b42ccf to a27190d Compare August 17, 2026 09:38
@Julusian
Julusian merged commit e04eb99 into Sofie-Automation:main Aug 17, 2026
23 of 24 checks passed
@Julusian
Julusian deleted the feat/replace-meteor-check branch August 17, 2026 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Contribution from SuperFly.tv Contributions sponsored by SuperFly.tv Goodbye Meteor!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants