{"record":{"id":"a181df2ac320c567","repo":"jquense/yup","slug":"yup-reach-cannot-implicitly-index-into-a-tuple-typ","errorCode":null,"errorMessage":"Yup.reach cannot implicitly index into a tuple type. the path part \"${lastPartDebug}\" must contain an index to the tuple element, e.g. \"${lastPartDebug}[0]\"","messagePattern":"Yup\\.reach cannot implicitly index into a tuple type\\. the path part \"(.+?)\" must contain an index to the tuple element, e\\.g\\. \"(.+?)\\[0\\]\"","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/util/reach.ts","lineNumber":31,"sourceCode":"  parent: any;\n  parentPath: string;\n} {\n  let parent: any, lastPart: string, lastPartDebug: string;\n\n  // root path: ''\n  if (!path) return { parent, parentPath: path, schema };\n\n  forEach(path, (_part, isBracket, isArray) => {\n    let part = isBracket ? _part.slice(1, _part.length - 1) : _part;\n\n    schema = schema.resolve({ context, parent, value });\n\n    let isTuple = schema.type === 'tuple';\n    let idx = isArray ? parseInt(part, 10) : 0;\n\n    if (schema.innerType || isTuple) {\n      if (isTuple && !isArray)\n        throw new Error(\n          `Yup.reach cannot implicitly index into a tuple type. the path part \"${lastPartDebug}\" must contain an index to the tuple element, e.g. \"${lastPartDebug}[0]\"`,\n        );\n      if (value && idx >= value.length) {\n        throw new Error(\n          `Yup.reach cannot resolve an array item at index: ${_part}, in the path: ${path}. ` +\n            `because there is no value at that index. `,\n        );\n      }\n      parent = value;\n      value = value && value[idx];\n      schema = isTuple ? schema.spec.types[idx] : schema.innerType!;\n    }\n\n    // sometimes the array index part of a path doesn't exist: \"nested.arr.child\"\n    // in these cases the current part is the next schema and should be processed\n    // in this iteration. For cases where the index signature is included this\n    // check will fail and we'll handle the `child` part on the next iteration like normal\n    if (!isArray) {","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/jquense/yup/blob/ff31eee8a2b10c938bb3a22544d9e33957a8cf01/src/util/reach.ts#L13-L49","documentation":"When reach()/getIn() traverses a path into a tuple schema, each path part must carry an explicit array index because tuples have heterogeneous, positional element types. This Error is thrown when a tuple is encountered but the current path part has no [index] bracket.","triggerScenarios":"yup.reach(tupleSchema, 'myTuple') or 'nested.myTuple' where myTuple is a tuple — the part must be 'myTuple[0]' to select an element.","commonSituations":"Reusing plain-object paths against schemas converted to tuples; forgetting bracket syntax when tuple types were introduced in a schema refactor (yup.array() -> yup.tuple()).","solutions":["Append an index to the path part: 'myTuple[0]'","Change the schema field from tuple() back to array() if positional types aren't needed","Use schema.at()/get on the tuple schema directly instead of reach"],"exampleFix":"// before\nyup.reach(schema, 'user.coords');\n// after\nyup.reach(schema, 'user.coords[0]');","handlingStrategy":"validation","validationCode":"function pathHasTupleIndex(path) {\n  return path.split('.').every(p => !p.startsWith('coords') || /\\[\\d+\\]$/.test(p));\n}","typeGuard":"function hasTupleIndex(part: string): boolean {\n  return /\\[\\d+\\]$/.test(part);\n}","tryCatchPattern":"try { return yup.reach(schema, path); } catch (e) { if (/implicitly index into a tuple/.test(e.message)) return yup.reach(schema, path + '[0]'); throw e; }","preventionTips":["Document tuple fields and require bracket-index syntax in path builders","Use array() instead of tuple() when element types are uniform","Unit-test reach() paths against the real schema"],"tags":["path-resolution","tuple","reach"],"backgroundTag":"invalid-path-expression","analyzedSha":"ff31eee8a2b10c938bb3a22544d9e33957a8cf01","analyzedAt":"2026-08-31T21:51:03.773Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}