can1357/oh-my-pi · error · Error

${result.summary}

Error message

${result.summary}

What it means

The zod-compat `parse()` runs the schema and, when validation produces ArkType errors, throws a standard Error whose message is `result.summary` — a human-readable list of all validation failures. This is the compat layer's analogue of zod's ZodError: a failed assertion on the parsed input, not a library bug.

Source

Thrown at packages/omptype/src/zod.ts:117

		case "sub":
			return isStringKeyIR(ir.schema.ir);
		default:
			return false;
	}
}

function decorate<Out>(schema: Decoratable<Out>, optional = false): ZodLikeSchema<Out> {
	const next = (inner: Decoratable<Out>, nextOptional = optional): ZodLikeSchema<Out> => decorate(inner, nextOptional);
	const withObjectExtras = (extras: "keep" | "reject" | "delete"): ZodLikeSchema<Out> => {
		if (schema.ir.k !== "object") throw new OmpTypeError("object mode requires an object schema");
		return next(restrictBase(schema, { ...schema.ir, extras }));
	};
	Object.defineProperty(schema, "isOptional", { value: optional, enumerable: false });

	return Object.assign(schema, {
		parse(value: unknown): Out {
			const result = schema(value);
			if (result instanceof type.errors) throw new Error(result.summary);
			return result;
		},
		safeParse(value: unknown): ZodLikeSafeParseResult<Out> {
			const result = schema(value);
			if (!(result instanceof type.errors)) return { success: true, data: result };
			return {
				success: false,
				error: {
					message: result.summary,
					issues: result.map(issue => ({ path: [...issue.path], message: issue.problem })),
				},
			};
		},
		min(bound: number): ZodLikeSchema<Out> {
			const ir = schema.ir;
			if (ir.k === "string" || ir.k === "array") {
				lengthBound("min", schema, bound);
				const min = ir.min === undefined ? bound : Math.max(ir.min, bound);

View on GitHub (pinned to 9690622007)

Solutions

  1. Read `err.message` — the summary lists each failed path and reason; fix the input data accordingly.
  2. Use `safeParse()` instead to receive `{ success: false, error }` without throwing, and handle the failure branch.
  3. Update the schema or the producer of the data so shapes align (optional fields, defaults, unions).

Example fix

// before
const user = UserSchema.parse(rawBody); // throws on bad payload
// after
const res = UserSchema.safeParse(rawBody);
if (!res.success) return respond(400, res.error);
const user = res.data;
Defensive patterns

Strategy: try-catch

Validate before calling

// validate before parse by checking required fields yourself, or prefer safeParse:
const res = schema.safeParse(input);
if (!res.success) {
  // res.error / failure summary available without throwing
}

Type guard

function isParseSuccess<T>(r: ZodLikeSafeParseResult<T>): r is { success: true; data: T } {
  return r.success;
}

Try / catch

try {
  const value = schema.parse(payload);
} catch (err) {
  if (err instanceof Error && !(err instanceof TypeError)) {
    // message is the validation summary — log/return 400 with it
    return badRequest(err.message);
  }
  throw err;
}

Prevention

When it happens

Trigger: `schema.parse(value)` where value fails any constraint: wrong type, missing required property, failed refinement, out-of-range string/number bounds.

Common situations: Parsing untrusted API payloads or JSON config that doesn't match the schema; schema tightened after a field became required while old data still lacks it; passing already-parsed/transformed objects with altered shapes.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/42fa7596fbe0fa44. Report an issue: GitHub.