From 69a5195b62161174bfd55c68c482658122ee75df Mon Sep 17 00:00:00 2001 From: Jake Ruesink Date: Wed, 11 Nov 2026 15:23:36 -0600 Subject: [PATCH 1/3] Check a resource exists before deleting it, and give every failure an error phase Live in ChatGPT, deleting a product that did not exist returned 200 deleted: true. Medusa's DELETE routes echo deleted: true for any id (57 admin route files do), and GET /admin/collections/{id} answers 200 {} for a missing collection. delete_api now reads the same path first when it has a GET; a 404 or an empty body stops the DELETE with error.phase 'precheck', and a successful delete reports which GET found the resource. Also from the same report: - refusals carry structuredContent with error.phase 'refused', so every failure has an error object - spec_revision is on successful results and dry runs, not only failures - schema_check says no_body when no body was sent, before no_schema (the export dry run read no_schema) - the README no longer lists a missing scope as a refusal: it is an HTTP 403 scope challenge Co-Authored-By: Claude Opus 5.5 --- .../integration-tests/http/mcp-write.spec.ts | 59 ++++++++++- packages/medusa-mcp/README.md | 25 +++-- packages/medusa-mcp/src/mcp/server.ts | 97 ++++++++++++++++--- 3 files changed, 157 insertions(+), 24 deletions(-) diff --git a/apps/medusa/integration-tests/http/mcp-write.spec.ts b/apps/medusa/integration-tests/http/mcp-write.spec.ts index 718e4ac34..254c413b8 100644 --- a/apps/medusa/integration-tests/http/mcp-write.spec.ts +++ b/apps/medusa/integration-tests/http/mcp-write.spec.ts @@ -90,6 +90,7 @@ medusaIntegrationTestRunner({ executed: false, schema_check: 'passed', limits: expect.stringContaining('Nothing was sent to Medusa'), + spec_revision: expect.any(String), changes: [ { field: 'description', current: 'Smooth and sweet.', proposed: 'Rich, chocolatey, and caffeine-free.' }, ], @@ -149,22 +150,75 @@ medusaIntegrationTestRunner({ operation: 'DELETE /admin/products/{id}', path_params: { id: productId }, }); - expect(deleted.structuredContent).toMatchObject({ status: 200, body: { id: productId, deleted: true } }); + expect(deleted.structuredContent).toMatchObject({ + status: 200, + body: { id: productId, deleted: true }, + precheck: { operation: 'GET /admin/products/{id}', found: true }, + spec_revision: expect.any(String), + }); await expect(product()).rejects.toThrow(); }); + it('does not send a DELETE for a resource that does not exist, since Medusa would answer deleted: true', async () => { + // Medusa's DELETE route reports success for any id, and GET /admin/collections/{id} answers 200 {} for a missing + // collection, so both a 404 and an empty body must stop the delete. + const missingProduct = await callTool(api, fullToken, 'delete_api', { + operation: 'DELETE /admin/products/{id}', + path_params: { id: 'prod_does_not_exist' }, + }); + expect(missingProduct.isError).toBe(true); + expect(missingProduct.structuredContent).toMatchObject({ + operation: 'DELETE /admin/products/{id}', + executed: false, + error: { + phase: 'precheck', + check: 'GET /admin/products/{id}', + status: 404, + hint: expect.stringContaining('Nothing was deleted'), + }, + }); + expect(missingProduct.content[0].text).toContain('The DELETE was not sent.'); + + const [collection] = await getContainer() + .resolve(Modules.PRODUCT) + .createProductCollections([{ title: 'MCP check collection', handle: 'mcp-check-collection' }]); + const first = await callTool(api, fullToken, 'delete_api', { + operation: 'DELETE /admin/collections/{id}', + path_params: { id: collection.id }, + }); + expect(first.structuredContent).toMatchObject({ status: 200, precheck: { found: true } }); + const again = await callTool(api, fullToken, 'delete_api', { + operation: 'DELETE /admin/collections/{id}', + path_params: { id: collection.id }, + }); + expect(again.structuredContent).toMatchObject({ + executed: false, + error: { phase: 'precheck', check: 'GET /admin/collections/{id}', status: 200 }, + }); + }); + it('refuses blocked writes and the wrong tool for an operation', async () => { const blocked = await callTool(api, fullToken, 'write_api', { operation: 'POST /admin/api-keys', body: { title: 'agent key', type: 'secret' }, }); expect(blocked.content[0].text).toContain('blocked for agents'); + expect(blocked.structuredContent).toMatchObject({ + operation: 'POST /admin/api-keys', + error: { + phase: 'refused', + message: expect.stringContaining('blocked for agents'), + hint: 'Nothing was sent to Medusa.', + }, + spec_revision: expect.any(String), + }); const wrongTool = await callTool(api, fullToken, 'write_api', { operation: 'DELETE /admin/products/{id}', path_params: { id: productId }, }); expect(wrongTool.content[0].text).toContain('Use delete_api'); + expect(wrongTool.structuredContent?.error).toMatchObject({ phase: 'refused' }); }); it('audits refused, executed, and previewed write attempts with their path parameters', async () => { @@ -230,6 +284,7 @@ medusaIntegrationTestRunner({ executed: false, schema_check: 'passed', limits: expect.stringContaining('the real call can still be rejected'), + spec_revision: expect.any(String), proposed: draft, current: null, note: '"Create Product": current values are shown only for a write to a path that ends in a resource id, so only the proposal is shown.', @@ -285,6 +340,7 @@ medusaIntegrationTestRunner({ operation: 'POST /admin/products/export', dry_run: true, }); + expect(action.structuredContent?.schema_check).toBe('no_body'); expect(action.structuredContent?.note).toBe( '"Export Products": current values are shown only for a write to a path that ends in a resource id, so only the proposal is shown.', ); @@ -304,6 +360,7 @@ medusaIntegrationTestRunner({ executed: false, schema_check: 'passed', limits: expect.stringContaining('Nothing was sent to Medusa'), + spec_revision: expect.any(String), proposed: { description: 'Proposed.' }, current: null, note: 'Current values need the mcp:read scope.', diff --git a/packages/medusa-mcp/README.md b/packages/medusa-mcp/README.md index 23f768de9..3e992d09c 100644 --- a/packages/medusa-mcp/README.md +++ b/packages/medusa-mcp/README.md @@ -23,22 +23,31 @@ Status: in development on `feat/medusa-mcp`. Design and plan: Arbor thread DEM-1 | `describe_api` | `mcp:read` | Parameters, request body, and response shape for one operation. | | `read_api` | `mcp:read` | Calls a GET as the signed-in admin. | | `write_api` | `mcp:write` | Calls a POST, PUT, or PATCH after validating the body. `dry_run` previews current vs proposed values without sending anything. | -| `delete_api` | `mcp:delete` | Calls a DELETE. Marked destructive. | +| `delete_api` | `mcp:delete` | Calls a DELETE. Marked destructive. When the same path has a GET, checks the resource exists first, because Medusa answers `deleted: true` for any id. | A dry run checks the body against the published spec only. Medusa enforces business rules in its workflows, which no spec describes: creating a product without `options` passes the schema and fails in Medusa's create workflow. So every preview says it was not executed and whether the body was checked (`schema_check`), and a failed call returns an `error` object with the phase (`schema` or `medusa`), Medusa's `type`, `code`, and `message` when Medusa sends them (`code` is often absent), and a hint for the status, so -an agent can correct the body and call again. `spec_revision` sits beside `error`, at the top of the result. +an agent can correct the body and call again. Every result carries `spec_revision`, the catalog it was resolved +against, at the top level beside `error`. A failed call is an MCP tool result with `isError: true`, as the MCP spec asks for execution errors, not a JSON-RPC -error. ChatGPT presents such a result as a tool exception carrying the text. The result takes one of three shapes: +error. ChatGPT presents such a result as a tool exception carrying the text. Each failure has an `error.phase`: -| Failure | Text content | `structuredContent` | -| --- | --- | --- | -| Medusa rejected the call | The same JSON as `structuredContent` | `operation`, `status`, `body`, `error` (`phase: 'medusa'`), `spec_revision` | -| The body failed the schema | A readable list of problems | `operation`, `error` (`phase: 'schema'`, `problems`, `hint`), `spec_revision` | -| Refused before any call: unknown operation, wrong tool, blocked by policy, missing scope, rate limit, a body that is not JSON, bad path parameters | A readable message | None | +| `error.phase` | When | Text content | Reached Medusa | +| --- | --- | --- | --- | +| `medusa` | Medusa rejected the call. `structuredContent` adds `status` and `body`. | The same JSON as `structuredContent` | Yes | +| `schema` | The body failed the published schema. `error.problems` lists why. | A readable list of problems | No | +| `precheck` | `delete_api` found no such resource: a 404, or Medusa's 200 with an empty body. `error.check` names the GET. | A readable message | Only the GET | +| `refused` | Unknown operation, wrong tool, blocked by policy, rate limit, a body that is not JSON, or bad path parameters. | A readable message | No | + +A token without the tool's scope gets no tool result at all: the server answers HTTP 403 with a `WWW-Authenticate` +challenge naming the scope, so the client can ask the user for more access. + +A successful delete reports `precheck`: the GET that found the resource, or `null` when the path has no GET to check +with. The check reports only that the resource exists, never its fields, so it shows a token without `mcp:read` +nothing that the DELETE would not. Calls run against Medusa's own API as the admin who connected, with a short-lived admin JWT, so Medusa's permissions and validators apply. A built-in blocklist (`src/mcp/policy.ts`) keeps agents away from auth, diff --git a/packages/medusa-mcp/src/mcp/server.ts b/packages/medusa-mcp/src/mcp/server.ts index 6a820525b..5e2e6ade7 100644 --- a/packages/medusa-mcp/src/mcp/server.ts +++ b/packages/medusa-mcp/src/mcp/server.ts @@ -49,6 +49,17 @@ function dryRunLimits(check: SchemaCheck): string { ); } +/** The resource object in a GET response, such as `product` in `{ product: {...} }`. Medusa answers some missing + * resources with 200 and an empty body (`GET /admin/collections/{id}` returns `{}`), so callers must check for it. */ +function resourceIn(body: unknown): Record | undefined { + return Object.values((body as Record) ?? {}).find( + (value) => value && typeof value === 'object' && !Array.isArray(value), + ) as Record | undefined; +} + +/** A path that ends in a path parameter names one resource, which a GET on the same path can read. */ +const ONE_RESOURCE = /\{[^}]+\}$/; + /** Advice for an agent on a failed call, by status. Medusa's own message says what to change. */ function errorHint(status: number): string { if (status === 400) { @@ -106,16 +117,26 @@ export function buildMcpServer(registry: ApiRegistry, target: ExecutionTarget): }, ); + const specRevision = catalog.spec.revision.slice(0, 12); + + /** A call stopped before anything reached Medusa: the reason as text, plus the same `error` shape as other failures. */ + const refusal = (message: string, operation?: string): ToolResult => + fail(message, { + ...(operation ? { operation } : {}), + error: { phase: 'refused', message, hint: 'Nothing was sent to Medusa.' }, + spec_revision: specRevision, + }); + const lookup = (key: unknown): CatalogOperation | ToolResult => { const operation = typeof key === 'string' ? catalog.byKey.get(key.trim()) : undefined; return ( - operation ?? fail(`Unknown operation "${String(key)}". Use search_api to find the exact "METHOD /path" key.`) + operation ?? refusal(`Unknown operation "${String(key)}". Use search_api to find the exact "METHOD /path" key.`) ); }; const limited = (kind: 'call' | 'change') => { const message = takeRateLimit(target.tokenId, kind); - return message ? fail(message) : undefined; + return message ? refusal(message) : undefined; }; const declaredFor = (operation: CatalogOperation) => { @@ -127,7 +148,7 @@ export function buildMcpServer(registry: ApiRegistry, target: ExecutionTarget): try { return await executeOperation(target, operation, declaredFor(operation), args); } catch (error) { - if (error instanceof ExecutionError) return fail(error.message); + if (error instanceof ExecutionError) return refusal(error.message, operation.operation); throw error; } }; @@ -139,19 +160,23 @@ export function buildMcpServer(registry: ApiRegistry, target: ExecutionTarget): const operation = lookup(args.operation); if ('content' in operation) return operation; if (operation.blocked_by) { - return fail(`${operation.operation} is blocked for agents by the "${operation.blocked_by}" rule.`); + return refusal( + `${operation.operation} is blocked for agents by the "${operation.blocked_by}" rule.`, + operation.operation, + ); } if (operation.tool !== tool) { - return fail(`${operation.operation} is not handled by ${tool}. Use ${operation.tool ?? 'another tool'} instead.`); + return refusal( + `${operation.operation} is not handled by ${tool}. Use ${operation.tool ?? 'another tool'} instead.`, + operation.operation, + ); } return operation; }; - const specRevision = catalog.spec.revision.slice(0, 12); - const resultOf = (operation: CatalogOperation, result: ExecutionResult | ToolResult): ToolResult => { if ('content' in result) return result; - if (result.status < 400) return ok({ operation: operation.operation, ...result }); + if (result.status < 400) return ok({ operation: operation.operation, ...result, spec_revision: specRevision }); const error = { phase: 'medusa', status: result.status, @@ -289,11 +314,14 @@ export function buildMcpServer(registry: ApiRegistry, target: ExecutionTarget): if (contentTypes.length && !contentTypes.some((type) => type.includes('json'))) { return refused( args, - fail(`${operation.operation} takes ${contentTypes.join(' or ')}, which write_api cannot send.`), + refusal( + `${operation.operation} takes ${contentTypes.join(' or ')}, which write_api cannot send.`, + operation.operation, + ), ); } const schema = requestBody?.content?.['application/json']?.schema; - const schemaCheck: SchemaCheck = !schema ? 'no_schema' : args.body === undefined ? 'no_body' : 'passed'; + const schemaCheck: SchemaCheck = args.body === undefined ? 'no_body' : !schema ? 'no_schema' : 'passed'; if (schema && args.body !== undefined) { const problems = validateBody(catalog.spec, operation.area, schema, args.body); if (problems.length) { @@ -340,7 +368,14 @@ export function buildMcpServer(registry: ApiRegistry, target: ExecutionTarget): const args = input as ToolArgs; const operation = resolveFor('delete_api', args); if ('content' in operation) return refused(args, operation); - return audited(args, () => executeAudited(operation, args)); + return audited(args, async () => { + const precheck = await findBeforeDelete(operation, args); + if (precheck && 'content' in precheck) return refused(args, precheck); + const result = await executeAudited(operation, args); + return result.isError || !result.structuredContent + ? result + : ok({ ...result.structuredContent, precheck: precheck ?? null }); + }); }, ); @@ -371,6 +406,39 @@ export function buildMcpServer(registry: ApiRegistry, target: ExecutionTarget): return resultOf(operation, result); } + /** + * Medusa's DELETE routes answer `deleted: true` whether or not the resource existed, so a delete cannot show that + * anything was removed. When the same path has a GET, read it first: a missing resource stops the DELETE and returns + * why. Only existence is reported, never the body, so a token without mcp:read learns nothing a DELETE would not. + */ + async function findBeforeDelete( + operation: CatalogOperation, + args: ToolArgs, + ): Promise<{ operation: string; found: true } | ToolResult | undefined> { + const read = catalog.byKey.get(`GET ${operation.path}`); + if (!ONE_RESOURCE.test(operation.path) || !read || read.blocked_by) return undefined; + const current = await run(read, { path_params: args.path_params }); + if ('content' in current) return current; + if (current.status === 404 || (current.status < 400 && !resourceIn(current.body))) { + const message = + medusaError(current.body).message ?? `${read.operation} returned no resource for these path parameters.`; + return fail(`${message} The DELETE was not sent.`, { + operation: operation.operation, + executed: false, + error: { + phase: 'precheck', + check: read.operation, + status: current.status, + message, + hint: 'Nothing was deleted, because the resource does not exist. Check the path parameters.', + }, + spec_revision: specRevision, + }); + } + // Any other failure says nothing about existence, so the DELETE goes ahead without claiming a check passed. + return current.status < 400 ? { operation: read.operation, found: true } : undefined; + } + /** * Previews a write without sending it. For an operation on one resource (its path ends in a path parameter), shows * the current value of each top-level body field next to the proposed one, by reading the same path with GET. A @@ -385,11 +453,12 @@ export function buildMcpServer(registry: ApiRegistry, target: ExecutionTarget): executed: false, schema_check: schemaCheck, limits: dryRunLimits(schemaCheck), + spec_revision: specRevision, }; const proposalOnly = (note: string) => ok({ ...preview, proposed: args.body ?? null, current: null, note }); const read = catalog.byKey.get(`GET ${operation.path}`); - if (!/\{[^}]+\}$/.test(operation.path)) { + if (!ONE_RESOURCE.test(operation.path)) { // The spec does not say whether a POST creates, updates, or acts, so the note names the operation and states what // the preview does rather than guessing what the call will do. const name = operation.summary ? `"${operation.summary}"` : 'This operation'; @@ -406,9 +475,7 @@ export function buildMcpServer(registry: ApiRegistry, target: ExecutionTarget): if ('content' in current) return current; if (current.status >= 400) return resultOf(read, current); - const resource = Object.values((current.body as Record) ?? {}).find( - (value) => value && typeof value === 'object' && !Array.isArray(value), - ) as Record | undefined; + const resource = resourceIn(current.body); const changes = fields.map((field) => ({ field, current: resource?.[field] ?? null, From 1fe73736b9ec16d6a88a0ad59ed58184a04260fe Mon Sep 17 00:00:00 2001 From: Jake Ruesink Date: Wed, 11 Nov 2026 15:34:27 -0600 Subject: [PATCH 2/3] Let an inconclusive delete precheck go ahead instead of blocking From review: three cases stopped a DELETE that could succeed. A route returning the resource directly ({id, ...}) read as missing; a GET that timed out or dropped its connection threw before the DELETE ran; and a GET body cut off at the size limit read as missing. A body with an id is now the resource, and a transport failure or truncated body counts as inconclusive: the DELETE runs with precheck: null. Co-Authored-By: Claude Opus 5.5 --- .../integration-tests/http/mcp-write.spec.ts | 11 ++++++++ .../src/mcp/__tests__/mcp.unit.spec.ts | 11 ++++++++ packages/medusa-mcp/src/mcp/server.ts | 26 ++++++++++++++----- 3 files changed, 41 insertions(+), 7 deletions(-) diff --git a/apps/medusa/integration-tests/http/mcp-write.spec.ts b/apps/medusa/integration-tests/http/mcp-write.spec.ts index 254c413b8..000250e73 100644 --- a/apps/medusa/integration-tests/http/mcp-write.spec.ts +++ b/apps/medusa/integration-tests/http/mcp-write.spec.ts @@ -195,6 +195,17 @@ medusaIntegrationTestRunner({ executed: false, error: { phase: 'precheck', check: 'GET /admin/collections/{id}', status: 200 }, }); + + // A GET too large to read whole cannot show whether the resource exists, so the DELETE goes ahead unchecked. + await getContainer() + .resolve(Modules.PRODUCT) + .updateProducts(productId, { description: 'x'.repeat(80 * 1024) }); + const unchecked = await callTool(api, fullToken, 'delete_api', { + operation: 'DELETE /admin/products/{id}', + path_params: { id: productId }, + }); + expect(unchecked.structuredContent).toMatchObject({ status: 200, body: { deleted: true }, precheck: null }); + await expect(product()).rejects.toThrow(); }); it('refuses blocked writes and the wrong tool for an operation', async () => { diff --git a/packages/medusa-mcp/src/mcp/__tests__/mcp.unit.spec.ts b/packages/medusa-mcp/src/mcp/__tests__/mcp.unit.spec.ts index 0166e6547..23068ba8a 100644 --- a/packages/medusa-mcp/src/mcp/__tests__/mcp.unit.spec.ts +++ b/packages/medusa-mcp/src/mcp/__tests__/mcp.unit.spec.ts @@ -6,6 +6,7 @@ import { buildCatalog } from '../catalog'; import { describeOperation } from '../describe'; import { appendQuery, buildRequestUrl, declaredParameters, ExecutionError, executeOperation } from '../execute'; import { BUILT_IN_BLOCKLIST, createPolicy } from '../policy'; +import { resourceIn } from '../server'; import { buildSearchIndex, queryIntent, tokenize } from '../search'; const spec = buildApiSpec({ projectRoot: path.join(__dirname, '../../openapi/__tests__/fixtures/valid') }); @@ -257,3 +258,13 @@ describe('search', () => { expect(ranks.find(({ query }) => query === 'update a product description')?.rank).toBe(1); }); }); + +describe('resourceIn', () => { + it('finds the resource nested under its key, or returned directly, and nothing in an empty body', () => { + expect(resourceIn({ product: { id: 'prod_1' } })).toEqual({ id: 'prod_1' }); + expect(resourceIn({ id: 'custom_1', title: 'Direct' })).toEqual({ id: 'custom_1', title: 'Direct' }); + expect(resourceIn({})).toBeUndefined(); + expect(resourceIn('{"product":')).toBeUndefined(); + expect(resourceIn(undefined)).toBeUndefined(); + }); +}); diff --git a/packages/medusa-mcp/src/mcp/server.ts b/packages/medusa-mcp/src/mcp/server.ts index 5e2e6ade7..e6c873506 100644 --- a/packages/medusa-mcp/src/mcp/server.ts +++ b/packages/medusa-mcp/src/mcp/server.ts @@ -49,12 +49,16 @@ function dryRunLimits(check: SchemaCheck): string { ); } -/** The resource object in a GET response, such as `product` in `{ product: {...} }`. Medusa answers some missing - * resources with 200 and an empty body (`GET /admin/collections/{id}` returns `{}`), so callers must check for it. */ -function resourceIn(body: unknown): Record | undefined { - return Object.values((body as Record) ?? {}).find( - (value) => value && typeof value === 'object' && !Array.isArray(value), - ) as Record | undefined; +/** The resource object in a GET response: `product` in Medusa's `{ product: {...} }`, or the body itself when a route + * returns the resource directly with an `id`. Medusa answers some missing resources with 200 and an empty body + * (`GET /admin/collections/{id}` returns `{}`), so callers must check for it. */ +export function resourceIn(body: unknown): Record | undefined { + if (!body || typeof body !== 'object' || Array.isArray(body)) return undefined; + const record = body as Record; + if (typeof record.id === 'string') return record; + return Object.values(record).find((value) => value && typeof value === 'object' && !Array.isArray(value)) as + | Record + | undefined; } /** A path that ends in a path parameter names one resource, which a GET on the same path can read. */ @@ -417,8 +421,16 @@ export function buildMcpServer(registry: ApiRegistry, target: ExecutionTarget): ): Promise<{ operation: string; found: true } | ToolResult | undefined> { const read = catalog.byKey.get(`GET ${operation.path}`); if (!ONE_RESOURCE.test(operation.path) || !read || read.blocked_by) return undefined; - const current = await run(read, { path_params: args.path_params }); + let current: Awaited>; + try { + current = await run(read, { path_params: args.path_params }); + } catch { + // A timeout or a dropped connection says nothing about existence; the DELETE decides. + return undefined; + } if ('content' in current) return current; + // A truncated body cannot show whether the resource is in it. + if (current.truncated) return undefined; if (current.status === 404 || (current.status < 400 && !resourceIn(current.body))) { const message = medusaError(current.body).message ?? `${read.operation} returned no resource for these path parameters.`; From 52ac1916af596727ae06dd241bb6c28e48281c37 Mon Sep 17 00:00:00 2001 From: Jake Ruesink Date: Wed, 11 Nov 2026 15:37:38 -0600 Subject: [PATCH 3/3] Stop a delete on a 404 even when the GET body was truncated From review: the truncation check ran before the 404 check, so a truncated 404 counted as inconclusive and the DELETE went ahead. A 404 now always stops the delete; only a truncated non-404 is inconclusive. Co-Authored-By: Claude Opus 5.5 --- packages/medusa-mcp/src/mcp/server.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/medusa-mcp/src/mcp/server.ts b/packages/medusa-mcp/src/mcp/server.ts index e6c873506..5d07404e9 100644 --- a/packages/medusa-mcp/src/mcp/server.ts +++ b/packages/medusa-mcp/src/mcp/server.ts @@ -429,9 +429,11 @@ export function buildMcpServer(registry: ApiRegistry, target: ExecutionTarget): return undefined; } if ('content' in current) return current; - // A truncated body cannot show whether the resource is in it. - if (current.truncated) return undefined; - if (current.status === 404 || (current.status < 400 && !resourceIn(current.body))) { + // A 404 says the resource is missing whatever its body. Otherwise a truncated body cannot show whether the resource + // is in it, so the check is inconclusive. + const missing = current.status === 404 || (!current.truncated && current.status < 400 && !resourceIn(current.body)); + if (current.truncated && !missing) return undefined; + if (missing) { const message = medusaError(current.body).message ?? `${read.operation} returned no resource for these path parameters.`; return fail(`${message} The DELETE was not sent.`, {