{"record":{"id":"4f67e897acda6e74","repo":"pubkey/rxdb","slug":"doc5","errorCode":"DOC5","errorMessage":"RxDB Error-Code: DOC5. Hint: Error messages are not included in RxDB core to reduce build size. To show the full error messages and to ensure that you do not make any mistakes when using RxDB, use the dev-mode plugin when you are in development mode: https://rxdb.info/dev-mode.html?console=error","messagePattern":"RxDB Error-Code: DOC5\\. Hint: Error messages are not included in RxDB core to reduce build size\\. To show the full error messages and to ensure that you do not make any mistakes when using RxDB, use the dev-mode plugin when you are in development mode: https://rxdb\\.info/dev-mode\\.html\\?console=error","errorType":"error_code","errorClass":"RxError","httpStatus":null,"severity":"error","filePath":"src/rx-document.ts","lineNumber":205,"sourceCode":"        );\n    },\n\n    /**\n     * populate the given path\n     */\n    populate(this: RxDocument, path: string): Promise<RxDocument | null> {\n        const schemaObj = getSchemaByObjectPath(\n            this.collection.schema.jsonSchema,\n            path\n        );\n        /**\n         * Validate the schema path BEFORE looking at the document value\n         * so that invalid paths and non-ref fields surface as DOC5/DOC6\n         * errors even when the value at that path happens to be falsy.\n         * Previously the `!value` short-circuit below swallowed these errors.\n         */\n        if (!schemaObj) {\n            throw newRxError('DOC5', {\n                path\n            });\n        }\n        const ref = schemaObj.ref\n            ? schemaObj.ref\n            : (schemaObj.type === 'array' && schemaObj.items && (schemaObj.items as any).ref\n                ? (schemaObj.items as any).ref\n                : undefined);\n        if (!ref) {\n            throw newRxError('DOC6', {\n                path,\n                schemaObj\n            });\n        }\n\n        const refCollection: RxCollection = this.collection.database.collections[ref];\n        if (!refCollection) {\n            throw newRxError('DOC7', {","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/pubkey/rxdb/blob/af6fb65f94cd70558d74c23799eda11ff1c15224/src/rx-document.ts#L187-L223","documentation":"DOC5 is thrown by RxDocument.populate() when the given path does not exist in the collection schema. Before reading the document value, RxDB validates that the path is a real schema path; a nonexistent path is a programming error, not an empty result. The validation was moved before the falsy-value check so invalid paths surface even when the stored value is falsy.","triggerScenarios":"Calling await doc.populate('friendId') where 'friendId' is not a path in the schema; a typo in the path; calling populate on a field that was removed or renamed in the schema; populate on an intermediate path that does not resolve via getSchemaByObjectPath.","commonSituations":"Renaming a foreign-key field without updating populate calls; confusing the ref field name with the referenced collection name; copy-pasting populate paths between collections with different schemas.","solutions":["Correct the path so it matches a schema field (the one holding the ref)","Check the schema definition declares the field, e.g. { type: 'string', ref: 'heroes' }","Run populate only on fields confirmed via collection.schema.jsonSchema"],"exampleFix":"// before\nawait doc.populate('friend'); // DOC5: no such schema path\n// after\nawait doc.populate('bestFriend'); // field exists in schema","handlingStrategy":"validation","validationCode":"import { getSchemaByObjectPath } from 'rxdb/plugins/schema-helper';\nfunction canPopulate(doc: RxDocument, path: string): boolean {\n  return !!getSchemaByObjectPath(doc.collection.schema.jsonSchema, path);\n}\nif (canPopulate(doc, 'bestFriend')) await doc.populate('bestFriend');","typeGuard":"function isSchemaPath(doc: RxDocument, path: string): boolean {\n  return !!getSchemaByObjectPath(doc.collection.schema.jsonSchema, path);\n}","tryCatchPattern":"try {\n  const referenced = await doc.populate(path);\n} catch (err) {\n  if (['DOC5', 'DOC6'].includes((err as any).code)) {\n    // fall back to raw value\n    return doc.get(path);\n  }\n  throw err;\n}","preventionTips":["Keep populate paths in typed constants next to the schema definition","Test populate() calls for every ref field in unit tests","Enable dev-mode plugin during development for full error text","Grep codebase for populate( after any schema rename"],"tags":["schema","populate","document-path"],"backgroundTag":"schema-path-not-found","analyzedSha":"af6fb65f94cd70558d74c23799eda11ff1c15224","analyzedAt":"2026-08-31T23:32:37.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}