{"record":{"id":"11b624dbe0bfc35b","repo":"gatsbyjs/gatsby","slug":"both-arguments-must-not-be-negative-and-end-must-b","errorCode":null,"errorMessage":"Both arguments must not be negative and end must be greater than start","messagePattern":"Both arguments must not be negative and end must be greater than start","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/gatsby/src/datastore/common/iterable.ts","lineNumber":51,"sourceCode":"      }\n    }\n  }\n\n  concat<U>(other: Iterable<U>): GatsbyIterable<T | U> {\n    return new GatsbyIterable(() => concatSequence(this, other))\n  }\n\n  map<U>(fn: (entry: T, index: number) => U): GatsbyIterable<U> {\n    return new GatsbyIterable(() => mapSequence(this, fn))\n  }\n\n  filter(predicate: (entry: T) => unknown): GatsbyIterable<T> {\n    return new GatsbyIterable(() => filterSequence(this, predicate))\n  }\n\n  slice(start: number, end?: number): GatsbyIterable<T> {\n    if ((typeof end !== `undefined` && end < start) || start < 0)\n      throw new Error(\n        `Both arguments must not be negative and end must be greater than start`\n      )\n    return new GatsbyIterable<T>(() => sliceSequence(this, start, end))\n  }\n\n  deduplicate(keyFn?: (entry: T) => unknown): GatsbyIterable<T> {\n    return new GatsbyIterable<T>(() => deduplicateSequence(this, keyFn))\n  }\n\n  forEach(callback: (entry: T, index: number) => unknown): void {\n    let i = 0\n    for (const value of this) {\n      callback(value, i++)\n    }\n  }\n\n  /**\n   * Assuming both this and the other iterable are sorted","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/gatsbyjs/gatsby/blob/e85d62f1779e353eaac1753211629a26d123e26c/packages/gatsby/src/datastore/common/iterable.ts#L33-L69","documentation":"GatsbyIterable.slice validates its bounds like Array.prototype.slice: a negative start, or an end less than start, throws. The fault is the arguments passed to .slice() on an iterable result (often from datastore scan helpers), not the data itself.","triggerScenarios":"Thrown at packages/gatsby/src/datastore/common/iterable.ts:51 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass non-negative start and ensure end >= start","Guard slice bounds before calling when they come from user input","Use undefined for end to slice to the finish"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e85d62f1779e353eaac1753211629a26d123e26c","analyzedAt":"2026-08-26T17:50:09.662Z","contentChangedAt":"2026-08-26T17:50:09.662Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}