{"record":{"id":"c58572cc4ead9bd5","repo":"jquense/yup","slug":"the-schema-does-not-contain-the-path-path-fa","errorCode":null,"errorMessage":"The schema does not contain the path: ${path}. (failed at: ${lastPartDebug} which is a type: \"${schema.type}\")","messagePattern":"The schema does not contain the path: (.+?)\\. \\(failed at: (.+?) which is a type: \"(.+?)\"\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/util/reach.ts","lineNumber":51,"sourceCode":"        );\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) {\n      if (!schema.fields || !schema.fields[part])\n        throw new Error(\n          `The schema does not contain the path: ${path}. ` +\n            `(failed at: ${lastPartDebug} which is a type: \"${schema.type}\")`,\n        );\n\n      parent = value;\n      value = value && value[part];\n      schema = schema.fields[part];\n    }\n\n    lastPart = part;\n    lastPartDebug = isBracket ? '[' + _part + ']' : '.' + _part;\n  });\n\n  return { schema, parent, parentPath: lastPart! };\n}\n\nfunction reach<P extends string, S extends ISchema<any>>(\n  obj: S,","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/jquense/yup/blob/ff31eee8a2b10c938bb3a22544d9e33957a8cf01/src/util/reach.ts#L33-L69","documentation":"When a path part is not an array index, getIn() looks it up in schema.fields. This Error is thrown when the current schema has no field matching that part, meaning the path does not exist in the schema. The message includes the failing part and the schema's type for debugging.","triggerScenarios":"yup.reach(objectSchema, 'wrongField'), a typo in the path, or reaching into a schema whose type doesn't support fields (e.g. a string) at that position.","commonSituations":"Renamed object keys without updating path strings; paths written for a different schema version; dynamic paths built from user input that doesn't match the schema shape.","solutions":["Fix the path to match an existing schema field (check spelling/case)","Verify the path against the schema definition before calling reach","For dynamic paths, validate the part against Object.keys(schema.fields)","If using noUnknown/cast flows, derive paths from the data's own shape carefully"],"exampleFix":"// before\nyup.reach(userSchema, 'emial');\n// after\nyup.reach(userSchema, 'email');","handlingStrategy":"validation","validationCode":"function schemaHasPath(schema: yup.AnyObjectSchema, path: string): boolean {\n  return path.split('.').every((part, i, parts) => {\n    const fields = (schema as any).fields ?? {};\n    if (!(part in fields)) return false;\n    schema = fields[part];\n    return true;\n  });\n}","typeGuard":"function fieldExists(schema: any, part: string): boolean {\n  return !!schema?.fields && Object.prototype.hasOwnProperty.call(schema.fields, part);\n}","tryCatchPattern":"try { return yup.reach(schema, path); } catch (e) { if (/does not contain the path/.test(e.message)) return null; throw e; }","preventionTips":["Derive paths from constants/types shared with the schema definition","Keep schema keys and path strings in sync during renames (grep for the old key)","Add a schemaHasPath guard before any user-driven reach() call"],"tags":["path-resolution","reach","schema-mismatch"],"backgroundTag":"invalid-path-expression","analyzedSha":"ff31eee8a2b10c938bb3a22544d9e33957a8cf01","analyzedAt":"2026-08-31T21:51:03.773Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}