litedb-org/LiteDB · error · LiteException
0
0
Error message
System collection '{name}' are not registered as system collection What it means
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.
Source
Thrown at LiteDB/Engine/Engine/SystemCollections.cs:19
using System;
using System.Collections.Generic;
using static LiteDB.Constants;
namespace LiteDB.Engine
{
public partial class LiteEngine
{
/// <summary>
/// Get registered system collection
/// </summary>
internal SystemCollection GetSystemCollection(string name)
{
if (_systemCollections.TryGetValue(name, out var sys))
{
return sys;
}
throw new LiteException(0, $"System collection '{name}' are not registered as system collection");
}
/// <summary>
/// Register a new system collection that can be used in query for input/output data
/// Collection name must starts with $
/// </summary>
internal void RegisterSystemCollection(SystemCollection systemCollection)
{
if (systemCollection == null) throw new ArgumentNullException(nameof(systemCollection));
_systemCollections[systemCollection.Name] = systemCollection;
}
/// <summary>
/// Register a new system collection that can be used in query for input data
/// Collection name must starts with $
/// </summary>
internal void RegisterSystemCollection(string collectionName, Func<IEnumerable<BsonDocument>> factory)View on GitHub (pinned to f906a5f850)
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.
Example fix
// before
var result = db.GetCollection("$coll").Query().ToList(); // typo
// after
var result = db.GetCollection("$cols").Query().ToList(); Defensive patterns
Strategy: validation
Validate before calling
// Validate system collection name before querying
var known = new[] { "$cols", "$sequences", "$indexes", "$database", "$transactions", "$snapshots" };
if (name.StartsWith("$") && !known.Contains(name))
throw new InvalidOperationException($"'{name}' is not a registered system collection."); Type guard
static bool IsRegisteredSystemCollection(string name, ISet<string> registered) => registered.Contains(name);
Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Related errors
AI-assisted analysis of litedb-org/LiteDB@f906a5f850 (2026-08-13).
Data as JSON: /api/errors/e51544afa3397e79.
Report an issue: GitHub.