{"record":{"id":"3f8ffec1a303b16d","repo":"Automattic/mongoose","slug":"could-not-normalize-ref-path-chunk-chunk-not-i","errorCode":null,"errorMessage":"Could not normalize ref path, chunk ${chunk} not in populated path","messagePattern":"Could not normalize ref path, chunk (.+?) not in populated path","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/helpers/populate/modelNamesFromRefPath.js","lineNumber":54,"sourceCode":"\n    let _refPath = '';\n    let _remaining = refPath;\n    // 2nd, 4th, etc. will be numeric props. For example: `[ 'a', '.0.', 'b' ]`\n    for (let i = 0; i < chunks.length; i += 2) {\n      const chunk = chunks[i];\n      if (\n        _remaining.length >= chunk.length + 1 &&\n        _remaining.charAt(chunk.length) === '.' &&\n        _remaining.slice(0, chunk.length) === chunk\n      ) {\n        _refPath += _remaining.substring(0, chunk.length) + chunks[i + 1];\n        _remaining = _remaining.substring(chunk.length + 1);\n      } else if (i === chunks.length - 1) {\n        _refPath += _remaining;\n        _remaining = '';\n        break;\n      } else {\n        throw new Error('Could not normalize ref path, chunk ' + chunk + ' not in populated path');\n      }\n    }\n\n    const refValue = mpath.get(_refPath, doc, lookupLocalFields);\n    let modelNames = Array.isArray(refValue) ? refValue : [refValue];\n    modelNames = utils.array.flatten(modelNames);\n    return modelNames;\n  }\n\n  const refValue = mpath.get(refPath, doc, lookupLocalFields);\n\n  let modelNames;\n  if (modelSchema != null && Object.hasOwn(modelSchema.virtuals, refPath)) {\n    modelNames = [modelSchema.virtuals[refPath].applyGetters(void 0, doc)];\n  } else {\n    modelNames = Array.isArray(refValue) ? refValue : [refValue];\n  }\n","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/Automattic/mongoose/blob/49cdab01366679723b487ecb754b38570f783289/lib/helpers/populate/modelNamesFromRefPath.js#L36-L72","documentation":"Error \"Could not normalize ref path, chunk ${chunk} not in populated path\" thrown in Automattic/mongoose.","triggerScenarios":"Thrown at lib/helpers/populate/modelNamesFromRefPath.js:54 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"49cdab01366679723b487ecb754b38570f783289","analyzedAt":"2026-08-21T22:54:00.882Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}