{"record":{"id":"e51544afa3397e79","repo":"litedb-org/LiteDB","slug":"0-e51544","errorCode":"0","errorMessage":"System collection '{name}' are not registered as system collection","messagePattern":"System collection '(.+?)' are not registered as system collection","errorType":"exception","errorClass":"LiteException","httpStatus":null,"severity":"error","filePath":"LiteDB/Engine/Engine/SystemCollections.cs","lineNumber":19,"sourceCode":"﻿using System;\nusing System.Collections.Generic;\nusing static LiteDB.Constants;\n\nnamespace LiteDB.Engine\n{\n    public partial class LiteEngine\n    {\n        /// <summary>\n        /// Get registered system collection\n        /// </summary>\n        internal SystemCollection GetSystemCollection(string name)\n        {\n            if (_systemCollections.TryGetValue(name, out var sys))\n            {\n                return sys;\n            }\n\n            throw new LiteException(0, $\"System collection '{name}' are not registered as system collection\");\n        }\n\n        /// <summary>\n        /// Register a new system collection that can be used in query for input/output data\n        /// Collection name must starts with $\n        /// </summary>\n        internal void RegisterSystemCollection(SystemCollection systemCollection)\n        {\n            if (systemCollection == null) throw new ArgumentNullException(nameof(systemCollection));\n\n            _systemCollections[systemCollection.Name] = systemCollection;\n        }\n\n        /// <summary>\n        /// Register a new system collection that can be used in query for input data\n        /// Collection name must starts with $\n        /// </summary>\n        internal void RegisterSystemCollection(string collectionName, Func<IEnumerable<BsonDocument>> factory)","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/litedb-org/LiteDB/blob/f906a5f850678719e39a39a006cb66dcae563cfa/LiteDB/Engine/Engine/SystemCollections.cs#L1-L37","documentation":"Thrown by GetSystemCollection when a name starting with '$' is queried but is not found in the internal system-collection registry. LiteDB registers built-in system collections (like $cols, $sequences, etc.) at engine startup; any unregistered '$'-prefixed name triggers this. This is a LiteException (code 0) from an internal method.","triggerScenarios":"Querying a collection whose name starts with '$' but is not a recognized system collection (e.g., a typo like `$coll` instead of `$cols`, or a custom name that was never registered via RegisterSystemCollection).","commonSituations":"Typo in a system collection name in a query string. Attempting to query a user-defined system collection that was never registered. Version differences where a system collection name changed or was removed. Code referencing '$'-prefixed collection names for user data by mistake.","solutions":["Check the exact system collection name spelling against the LiteDB version's documentation (e.g., $cols, $sequences, $indexes).","If you intended a user collection, rename it to not start with '$'.","If you need a custom system collection, register it via RegisterSystemCollection before querying."],"exampleFix":"// before\nvar result = db.GetCollection(\"$coll\").Query().ToList(); // typo\n// after\nvar result = db.GetCollection(\"$cols\").Query().ToList();","handlingStrategy":"validation","validationCode":"// Validate system collection name before querying\nvar known = new[] { \"$cols\", \"$sequences\", \"$indexes\", \"$database\", \"$transactions\", \"$snapshots\" };\nif (name.StartsWith(\"$\") && !known.Contains(name))\n    throw new InvalidOperationException($\"'{name}' is not a registered system collection.\");","typeGuard":"static bool IsRegisteredSystemCollection(string name, ISet<string> registered) => registered.Contains(name);","tryCatchPattern":null,"preventionTips":["Double-check system collection name spelling against the LiteDB version docs.","Do not use '$'-prefixed names for user collections.","Register custom system collections before querying them."],"tags":["engine","system-collection","query","lite-exception"],"backgroundTag":null,"analyzedSha":"f906a5f850678719e39a39a006cb66dcae563cfa","analyzedAt":"2026-08-13T21:56:30.148Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}