{"record":{"id":"48f67eae150a625c","repo":"pubkey/rxdb","slug":"doc4","errorCode":"DOC4","errorMessage":"RxDB Error-Code: DOC4. 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: DOC4\\. 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":161,"sourceCode":"\n            if (path === this.primaryPath) {\n                throw newRxError('DOC2');\n            }\n\n            // final fields cannot be modified and so also not observed\n            if (this.collection.schema.finalFields.includes(path)) {\n                throw newRxError('DOC3', {\n                    path\n                });\n            }\n\n            const schemaObj = getSchemaByObjectPath(\n                this.collection.schema.jsonSchema,\n                path\n            );\n\n            if (!schemaObj) {\n                throw newRxError('DOC4', {\n                    path\n                });\n            }\n        }\n\n        return this.$\n            .pipe(\n                map((data: any) => getProperty(data, path)),\n                distinctUntilChanged((prev: any, curr: any) => {\n                    /**\n                     * Use deepEqual for non-primitive values (objects/arrays)\n                     * because the default === comparison always fails across\n                     * document revisions since each revision creates new object references.\n                     */\n                    return deepEqual(prev, curr);\n                })\n            );\n    },","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/pubkey/rxdb/blob/af6fb65f94cd70558d74c23799eda11ff1c15224/src/rx-document.ts#L143-L179","documentation":"DOC4 is thrown by RxDocument.get$()/get() when the given object path is not defined in the collection's RxSchema. RxDB validates the path against the JSON schema before creating an observable, so a typo or a path outside the schema fails fast instead of emitting undefined. It guards against silently observing a field that can never exist.","triggerScenarios":"Calling doc.get$('name.lastname') or doc.get('field.x') where 'name.lastname' (or any intermediate segment) is not declared in the collection schema; using dot-notation paths that reference nested properties not present in the JSON schema; observing a removed or renamed field after a schema change.","commonSituations":"Field renamed in schema but queries/observables still use the old name; assuming nested paths are allowed without declaring nested objects in the schema; forgetting to update secondary indexes or UI bindings after a schema migration.","solutions":["Fix the path string so it matches a path defined in the collection's JSON schema","Verify with collection.schema.jsonSchema (or getSchemaByObjectPath) that the path exists","Enable the dev-mode plugin during development to get the full message including the offending path"],"exampleFix":"// before\ndoc.get$('nam.last'); // DOC4: path not in schema\n// after\ndoc.get$('name.last'); // path exists in the schema","handlingStrategy":"validation","validationCode":"import { getSchemaByObjectPath } from 'rxdb/plugins/schema-helper';\nfunction pathExists(doc: RxDocument, path: string): boolean {\n  return !!getSchemaByObjectPath(doc.collection.schema.jsonSchema, path);\n}\nif (!pathExists(doc, 'name.last')) throw new Error('unknown schema path');","typeGuard":"function hasSchemaPath(doc: RxDocument, path: string): path is string {\n  return !!getSchemaByObjectPath(doc.collection.schema.jsonSchema, path);\n}","tryCatchPattern":"try {\n  doc.get$(path).subscribe(render);\n} catch (err) {\n  if ((err as any).code === 'DOC4') console.warn('bad path', path);\n}","preventionTips":["Derive paths from constants or the schema itself instead of string literals","Run with the dev-mode plugin in development to get full messages","Add tests that assert schema paths used by UI code exist","Review schema migrations for renamed fields and update all path usages"],"tags":["schema","document-path","reactive-observables"],"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"}