Files
webstudio/packages/protocol/src/builder-api/errors.test.ts
T
Oleg Isonen 2808f06808 feat: Improve MCP validation errors with actionable guidance (#5881)
## What changed

- Return structured validation issues with stable codes, complete field
paths, constraints, and minimal correction examples.
- Preserve validation details through the Builder API, CLI, MCP, local
project sessions, and tRPC errors.
- Explain invalid expressions, JSX fragments, page selectors, component
inputs, asset updates, and project settings in terms an agent can act
on.
- Remove stack frames and credentials from parser details before
exposing them.
- Keep concise human-readable errors while making the complete
structured issues available to agents.

## Why

Agents previously received vague errors without enough information to
repair a request. They could repeat the same invalid call or require
manual intervention.

## User impact

CLI and MCP agents can now identify the exact invalid field, understand
the constraint, see a valid example, and retry with a corrected request.

## Validation

- Focused runtime, MCP, CLI, API, and tRPC validation tests.
- Structured error propagation tests across local and server execution.
- Typechecks and generated contract verification.
2026-07-15 11:33:36 +02:00

20 lines
477 B
TypeScript

import { expect, test } from "vitest";
import { isPublicApiRemoteErrorCode } from "./errors";
test("recognizes public API remote error codes", () => {
for (const code of [
"BAD_REQUEST",
"CONFLICT",
"FORBIDDEN",
"INTERNAL_SERVER_ERROR",
"INVALID_INPUT",
"NOT_FOUND",
"PROJECT_NOT_PUBLISHED",
"UNAUTHORIZED",
]) {
expect(isPublicApiRemoteErrorCode(code)).toBe(true);
}
expect(isPublicApiRemoteErrorCode("UNKNOWN")).toBe(false);
});