ruvnet/ruflo · error

Item at index ${i} passed predicate but should not have: ${J

Error message

Item at index ${i} passed predicate but should not have: ${JSON.stringify(items[i])}

What it means

assertNonePass() is the inverse helper: it throws on the first item for which the predicate returns true, printing the index and the item. Use it for invariants like no result carries an error; the throw proves at least one violating item exists.

Source

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

      );
    }
  }
}

/**
 * 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++) {
    if (predicate(items[i], i)) {
      throw new Error(
        message ?? `Item at index ${i} passed predicate but should not have: ${JSON.stringify(items[i])}`
      );
    }
  }
}

/**
 * Assert that two arrays have the same elements regardless of order
 *
 * @example
 * assertSameElements([1, 2, 3], [3, 1, 2]);
 */
export function assertSameElements<T>(actual: T[], expected: T[]): void {
  expect(actual).toHaveLength(expected.length);

  const actualSorted = [...actual].sort((a, b) =>
    JSON.stringify(a).localeCompare(JSON.stringify(b))
  );

View on GitHub (pinned to fa13ee4ad6)

Solutions

  1. Inspect the printed item; it is the concrete violation, then trace which producer set the forbidden state
  2. Tighten the predicate if it over-matches, for example check specific error codes instead of truthiness
  3. If the violating case is legitimately possible, split the assertion into allowed and disallowed subsets instead

Example fix

// before
assertNonePass(results, r => r.error); // throws at index 2

// after
assertNonePass(results, r => r.error?.fatal === true); // only fatal errors are forbidden
Defensive patterns

Strategy: validation

Validate before calling

// Enumerate violations before asserting
const violations = items
  .map((item, i) => ({ i, item }))
  .filter(({ item }) => predicate(item));
if (violations.length > 0) {
  console.error('violations:', violations);
}
assertNonePass(items, predicate);

Type guard

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

Prevention

When it happens

Trigger: At least one item satisfies the forbidden predicate (some result.error is truthy); a predicate that is too broad, matching on truthiness where a narrow check was intended; unexpected item shapes making the predicate accidentally true.

Common situations: One failed job in a batch that should be clean; warning paths setting error fields on non-errors; predicates written loosely during a rush.

Related errors


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