{"record":{"id":"b639d530ccb17744","repo":"ruvnet/ruflo","slug":"item-at-index-i-failed-predicate-json-string","errorCode":null,"errorMessage":"Item at index ${i} failed predicate: ${JSON.stringify(items[i])}","messagePattern":"Item at index (.+?) failed predicate: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/testing/src/helpers/assertion-helpers.ts","lineNumber":407,"sourceCode":"\n    lastIndex = index;\n  }\n}\n\n/**\n * Assert that all items in a collection pass a predicate\n *\n * @example\n * assertAllPass(results, result => result.success);\n */\nexport function assertAllPass<T>(\n  items: T[],\n  predicate: (item: T, index: number) => boolean,\n  message?: string\n): void {\n  for (let i = 0; i < items.length; i++) {\n    if (!predicate(items[i], i)) {\n      throw new Error(\n        message ?? `Item at index ${i} failed predicate: ${JSON.stringify(items[i])}`\n      );\n    }\n  }\n}\n\n/**\n * Assert that none of the items in a collection pass a predicate\n *\n * @example\n * assertNonePass(results, result => result.error);\n */\nexport function assertNonePass<T>(\n  items: T[],\n  predicate: (item: T, index: number) => boolean,\n  message?: string\n): void {\n  for (let i = 0; i < items.length; i++) {","sourceCodeStart":389,"sourceCodeEnd":425,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/testing/src/helpers/assertion-helpers.ts#L389-L425","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Look at the printed item; the index and payload identify exactly which element failed","Fix the producer of that element (the task or agent that yielded the failing item)","Pass a custom message only for context; keep the default when you need the item printed"],"exampleFix":"// before\nassertAllPass(results, r => r.success); // throws at index 3\n\n// after\nconst failed = results.filter(r => !r.success);\nassertAllPass(results, r => r.success, `failures: ${JSON.stringify(failed)}`);","handlingStrategy":"validation","validationCode":"// Surface all failures before asserting, not just the first\nconst failures = items\n  .map((item, i) => ({ i, item }))\n  .filter(({ item }) => !predicate(item));\nif (failures.length > 0) {\n  console.error('failing items:', failures);\n}\nassertAllPass(items, predicate);","typeGuard":"function allPass<T>(items: T[], predicate: (item: T, index: number) => boolean): boolean {\n  return items.every((item, i) => predicate(item, i));\n}","tryCatchPattern":null,"preventionTips":["Log the full failure set before asserting so one bad item does not hide others","Keep predicates pure and based on stable fields","Await completion of all items before asserting on async producers"],"tags":["testing","assertion","predicate","collections"],"backgroundTag":"predicate-assertion-failed","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","contentChangedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}