ruvnet/ruflo · error

Item at index ${i} failed predicate: ${JSON.stringify(items[

Error message

Item at index ${i} failed predicate: ${JSON.stringify(items[i])}

What it means

assertAllPass() evaluates the predicate over every item and throws on the first failure, printing the failing index and the serialized item unless a custom message is supplied. It is the strict every counterpart of the testing helpers: a single bad item fails the whole assertion.

Source

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

    lastIndex = index;
  }
}

/**
 * Assert that all items in a collection pass a predicate
 *
 * @example
 * assertAllPass(results, result => result.success);
 */
export function assertAllPass<T>(
  items: T[],
  predicate: (item: T, index: number) => boolean,
  message?: string
): void {
  for (let i = 0; i < items.length; i++) {
    if (!predicate(items[i], i)) {
      throw new Error(
        message ?? `Item at index ${i} failed predicate: ${JSON.stringify(items[i])}`
      );
    }
  }
}

/**
 * Assert that none of the items in a collection pass a predicate
 *
 * @example
 * assertNonePass(results, result => result.error);
 */
export function assertNonePass<T>(
  items: T[],
  predicate: (item: T, index: number) => boolean,
  message?: string
): void {
  for (let i = 0; i < items.length; i++) {

View on GitHub (pinned to fa13ee4ad6)

Solutions

  1. Look at the printed item; the index and payload identify exactly which element failed
  2. Fix the producer of that element (the task or agent that yielded the failing item)
  3. Pass a custom message only for context; keep the default when you need the item printed

Example fix

// before
assertAllPass(results, r => r.success); // throws at index 3

// after
const failed = results.filter(r => !r.success);
assertAllPass(results, r => r.success, `failures: ${JSON.stringify(failed)}`);
Defensive patterns

Strategy: validation

Validate before calling

// Surface all failures before asserting, not just the first
const failures = items
  .map((item, i) => ({ i, item }))
  .filter(({ item }) => !predicate(item));
if (failures.length > 0) {
  console.error('failing items:', failures);
}
assertAllPass(items, predicate);

Type guard

function allPass<T>(items: T[], predicate: (item: T, index: number) => boolean): boolean {
  return items.every((item, i) => predicate(item, i));
}

Prevention

When it happens

Trigger: One element in results or agents fails the predicate (for example result.success is false for one straggler); predicate using === against a field that is undefined on some items; supplying a custom message that hides the item payload.

Common situations: Suite-level invariants such as all tasks completed violated by one straggler; mixed-shape arrays where a field is missing on some items; flaky async producers.

Related errors


AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18). Data as JSON: /api/errors/b639d530ccb17744. Report an issue: GitHub.