ruvnet/ruflo · error

Invalid domain object: ${result.errors?.join(', ')}

Error message

Invalid domain object: ${result.errors?.join(', ')}

What it means

assertValidDomainObject() runs the supplied validator and throws when it reports valid false, joining the validator error strings into the message. It is a test-time assertion from the testing helpers: the failure means your fixture or factory produced an object that your own schema or validator rejects.

Source

Thrown at v3/@claude-flow/testing/src/helpers/assertion-helpers.ts:330

  memoryReduction?: number;
  startupTimeMs?: number;
  responseTimeMs?: number;
}

/**
 * Assert that a domain object is valid
 *
 * @example
 * assertValidDomainObject(user, UserSchema);
 */
export function assertValidDomainObject<T>(
  object: T,
  validator: (obj: T) => { valid: boolean; errors?: string[] }
): void {
  const result = validator(object);

  if (!result.valid) {
    throw new Error(`Invalid domain object: ${result.errors?.join(', ')}`);
  }
}

/**
 * Assert that a mock was only called with allowed arguments
 *
 * @example
 * assertOnlyCalledWithAllowed(mockFn, [['valid1'], ['valid2']]);
 */
export function assertOnlyCalledWithAllowed(
  mock: Mock,
  allowedCalls: unknown[][]
): void {
  const calls = mock.mock.calls;

  for (const call of calls) {
    const isAllowed = allowedCalls.some(
      allowed => JSON.stringify(call) === JSON.stringify(allowed)

View on GitHub (pinned to fa13ee4ad6)

Solutions

  1. Read the joined validator errors in the message; they name the exact failing constraints
  2. Fix the fixture or factory to satisfy the current schema, or update the schema if the fixture is the new truth
  3. Run the validator directly on the object while debugging to see the full error list

Example fix

// before
assertValidDomainObject({ id: 1 }, UserSchemaValidator); // throws: missing required fields

// after
assertValidDomainObject(makeValidUser(), UserSchemaValidator);
Defensive patterns

Strategy: validation

Validate before calling

// Inspect the validator result before asserting, for clearer diagnostics
const result = UserSchemaValidator(candidate);
if (!result.valid) {
  console.error('fixture validation errors:', result.errors);
}
assertValidDomainObject(candidate, UserSchemaValidator);

Type guard

function isValidDomainObject<T>(obj: T, validator: (o: T) => { valid: boolean; errors?: string[] }): obj is T {
  return validator(obj).valid;
}

Prevention

When it happens

Trigger: assertValidDomainObject(fixture, SchemaValidator) where the fixture is missing required fields or has wrong-typed fields; factory output drifting from the schema after a schema change.

Common situations: Schema updated with a new required field but fixtures not regenerated; validators distinguishing absent from undefined; refactors renaming fields.

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 ruvnet/ruflo@fa13ee4ad6 (2026-08-18). Data as JSON: /api/errors/3f68002019399ae2. Report an issue: GitHub.