Skip to content

bug(registry): meilisearch block is not 2.2-ready (removed seller link, middlewares shape, client pin, types, index orphans) #975

Open

Description

@overfullru-oss

Summary

The meilisearch registry block targets the 2.1.x data model and breaks on
a 2.2 project in several independent ways.

Environment

@mercurjs/core 2.2.0-canary.11 (also checked the canary.12 diff — the
block is unchanged), Medusa 2.13.4, block installed from the official
registry into a fresh basic project (bun).

Issues

1. Uses the removed product ↔ seller link

The sync subscriber/utils query product.seller.* via query.graph. On
2.2 the link no longer exists (sellers attach to variants through offers):

Entity 'Product' does not have property 'seller'

Every product sync fails. The store search route also hard-filters by
seller.status = "active" and hydrates seller.* — same failure.

2. middlewares.ts shape is not consumable

The block ships a middlewares file exporting a plain array, while Medusa
expects a default export of defineMiddlewares({ routes }). Result: the
search route's Zod validation never registers and the handler crashes on
validatedBody being undefined. Needs a defineMiddlewares wrapper (or
documentation that the consumer must merge it into their own
src/api/middlewares.ts).

3. Incompatible with current meilisearch npm client

With meilisearch@0.58 (resolved by ^ at install time) the service
throws MeiliSearch is not a constructor. Works with ^0.46. The block
should pin a known-good client range.

4. service.ts does not pass type-check

search() reads page / totalPages / hitsPerPage / totalHits from
SearchResponse, but in the client's types those fields exist only on the
paginated variant of the response union. medusa develop doesn't
type-check so it appears to work; the first medusa build fails with
TS2339.

5. Hard-deleted products stay in the index forever

The sync workflow removes unpublished products but never reconciles
documents whose DB row was hard-deleted (e.g. after a reseed). A
listAllIds-style reconciliation pass in the sync workflow fixes it
(we have a working implementation and can PR it).

Workarounds deployed in our project

All five patched locally and tracked in our UPSTREAM registry; happy to
turn any of them into PRs.

Activity

  1. vholik commented on Jun 22, 2026

    @vholik
    Collaborator

    Thanks for the detailed write-up — really helpful, and great catches.

    Most of this is now fixed and merged in #1048:

    1. Removed product ↔ seller link — on 2.2 the link is exposed as the plural product.sellers (a many-to-many list). The block now queries sellers.* and flattens to a single seller on the index document, and also filters on the live seller.status = "open" (the old "active" was never a valid status).
    2. middlewares.ts shape — the file now default-exports defineMiddlewares({ routes }) alongside the named allMeilisearchMiddlewares array, and PLUGIN.md documents merging it into your own src/api/middlewares.ts.
    3. npm client pin — pinned to meilisearch@^0.47.0 in the registry manifest so the CLI stops resolving the incompatible 0.58.
    4. service.ts type-check — the pagination fields are now read through an optional view, so medusa build no longer fails with TS2339.

    That leaves #5 (hard-deleted index orphan reconciliation), which I left out of this PR. Since you mentioned you already have a working listAllIds-style implementation — a PR would be very welcome and I'll happily review it. 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions