@mastra/server-adapters-test-suite 0.1.3-alpha.1 → 0.1.3-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @mastra/server-adapters-test-suite
2
2
 
3
+ ## 0.1.3-alpha.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Fixed run resume and time-travel conflict responses to include a machine-readable code alongside the existing error message across server adapters. HTTP status remains 409, with a JSON body such as: ([#27706](https://github.com/mastra-ai/mastra/pull/27706))
8
+
9
+ ```json
10
+ {
11
+ "error": "Run conflict",
12
+ "code": "AGENT_RESUME_ALREADY_CLAIMED"
13
+ }
14
+ ```
15
+
16
+ The shared handler exposes these conflict codes: `AGENT_RESUME_ALREADY_CLAIMED`, `WORKFLOW_RESUME_ALREADY_CLAIMED`, `AGENT_RESUME_RUN_NOT_SUSPENDED`, `WORKFLOW_RUN_NOT_SUSPENDED`, `WORKFLOW_TIME_TRAVEL_ALREADY_CLAIMED`, and `WORKFLOW_TIME_TRAVEL_RUN_RUNNING`.
17
+
18
+ - Updated dependencies [[`41b7f34`](https://github.com/mastra-ai/mastra/commit/41b7f3422a97f1385a285002b7e6f898eb5c7b06), [`6033024`](https://github.com/mastra-ai/mastra/commit/6033024193441ee88e24b98e9e59de90a6297e6e), [`179964b`](https://github.com/mastra-ai/mastra/commit/179964b95aacac31763a4a1aa2f2d1c652aa529d), [`ba7b0ea`](https://github.com/mastra-ai/mastra/commit/ba7b0eac045755d39d20dcf3a943ea5f8270b009), [`e8d7f8e`](https://github.com/mastra-ai/mastra/commit/e8d7f8e52da32b05f2e8501c1127128ae1a5d450), [`92034fa`](https://github.com/mastra-ai/mastra/commit/92034fa2a46a4f45af416c3201752342ead71d89)]:
19
+ - @mastra/core@1.79.0-alpha.6
20
+ - @mastra/server@1.79.0-alpha.6
21
+
3
22
  ## 0.1.3-alpha.1
4
23
 
5
24
  ### Patch Changes
package/dist/index.js CHANGED
@@ -1,3 +1,5 @@
1
+ import { ErrorCategory, ErrorDomain, MastraError } from "@mastra/core/error";
2
+ import { handleError } from "@mastra/server/handlers/error";
1
3
  import { HTTPException, SERVER_ROUTES, WorkflowRegistry, createRoute } from "@mastra/server/server-adapter";
2
4
  import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
3
5
  import * as zod from "zod";
@@ -2498,6 +2500,48 @@ function createRouteAdapterTestSuite(config) {
2498
2500
  expect(custom.getHandlerCalls()).toBe(1);
2499
2501
  });
2500
2502
  });
2503
+ describe("Run claim conflict responses (#27638)", () => {
2504
+ it.each([
2505
+ "AGENT_RESUME_ALREADY_CLAIMED",
2506
+ "WORKFLOW_RESUME_ALREADY_CLAIMED",
2507
+ "AGENT_RESUME_RUN_NOT_SUSPENDED",
2508
+ "WORKFLOW_RUN_NOT_SUSPENDED",
2509
+ "WORKFLOW_TIME_TRAVEL_ALREADY_CLAIMED",
2510
+ "WORKFLOW_TIME_TRAVEL_RUN_RUNNING"
2511
+ ])("lets clients identify %s without matching message text", async (code) => {
2512
+ const error = new MastraError({
2513
+ id: code,
2514
+ domain: ErrorDomain.MASTRA_WORKFLOW,
2515
+ category: ErrorCategory.USER
2516
+ }, "Run conflict");
2517
+ const route = {
2518
+ method: "POST",
2519
+ path: "/test/run-claim-conflict",
2520
+ responseType: "json",
2521
+ handler: async () => handleError(error, "Unable to resume")
2522
+ };
2523
+ const mutableServerRoutes = SERVER_ROUTES;
2524
+ const originalLength = mutableServerRoutes.length;
2525
+ mutableServerRoutes.push(route);
2526
+ let conflictApp;
2527
+ try {
2528
+ ({app: conflictApp} = await setupAdapter(context));
2529
+ } finally {
2530
+ mutableServerRoutes.splice(originalLength);
2531
+ }
2532
+ const response = await executeHttpRequest(conflictApp, {
2533
+ method: "POST",
2534
+ path: "/api/test/run-claim-conflict",
2535
+ body: {}
2536
+ });
2537
+ expect(response.status).toBe(409);
2538
+ expect(response.headers["content-type"]).toContain("application/json");
2539
+ expect(response.data).toEqual({
2540
+ error: "Run conflict",
2541
+ code
2542
+ });
2543
+ });
2544
+ });
2501
2545
  describe("Route Prefix", () => {
2502
2546
  it("should register routes at prefixed paths without double /api", async () => {
2503
2547
  const prefixedApp = (await setupAdapter(context, { prefix: "/v2" })).app;