{"record":{"id":"54c50e049989cf1e","repo":"litedb-org/LiteDB","slug":"0-54c50e","errorCode":"0","errorMessage":"{_name} do not support as output collection","messagePattern":"(.+?) do not support as output collection","errorType":"exception","errorClass":"LiteException","httpStatus":null,"severity":"error","filePath":"LiteDB/Engine/SystemCollections/SystemCollection.cs","lineNumber":43,"sourceCode":"            : this(name)\n        {\n            _input = input;\n        }\n\n        /// <summary>\n        /// Get system collection name (must starts with $)\n        /// </summary>\n        public string Name => _name;\n\n        /// <summary>\n        /// Get input data source factory\n        /// </summary>\n        public virtual IEnumerable<BsonDocument> Input(BsonValue options) => _input();\n\n        /// <summary>\n        /// Get output data source factory (must implement in inherit class)\n        /// </summary>\n        public virtual int Output(IEnumerable<BsonDocument> source, BsonValue options) => throw new LiteException(0, $\"{_name} do not support as output collection\");\n\n        /// <summary>\n        /// Static helper to read options arg as plain value or as document fields\n        /// </summary>\n        protected static BsonValue GetOption(BsonValue options, string key)\n        {\n            return GetOption(options, key, null);\n        }\n\n        /// <summary>\n        /// Static helper to read options arg as plain value or as document fields\n        /// </summary>\n        protected static BsonValue GetOption(BsonValue options, string key, BsonValue defaultValue)\n        {\n            if (options != null && options.IsDocument)\n            {\n                if (options.AsDocument.TryGetValue(key, out var value))\n                {","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/litedb-org/LiteDB/blob/f906a5f850678719e39a39a006cb66dcae563cfa/LiteDB/Engine/SystemCollections/SystemCollection.cs#L25-L61","documentation":"Thrown by the virtual SystemCollection.Output when a system collection that does not override Output is used as an INSERT/export target. The base implementation always throws; only $file/$file_json/$file_csv implement Output. So INSERT INTO $<read-only-collection> is rejected.","triggerScenarios":"INSERT INTO $collections SELECT ...; INSERT INTO $indexes; INSERT INTO $query; INSERT INTO any read-only system collection (those exposing only Input).","commonSituations":"Treating system collections as writable; attempting to populate metadata views; copy-pasting an export template and pointing it at a $-collection.","solutions":["Insert into a real user collection, not a system ($) collection.","For file export use $file/$file_json/$file_csv which do support Output.","Verify a system collection supports writes before targeting it with INSERT INTO."],"exampleFix":"// before\ndb.Execute(\"INSERT INTO $collections({ name:'x' })\"); // throws\n\n// after\ndb.Execute(\"INSERT INTO collections ({ name:'x' })\");","handlingStrategy":"validation","validationCode":"static readonly HashSet<string> WritableSys = new() { \"$file\", \"$file_json\", \"$file_csv\" };\nif (target.StartsWith(\"$\") && !WritableSys.Contains(target))\n    throw new ArgumentException($\"{target} is read-only; insert into a real collection\");","typeGuard":"static bool IsWritableCollection(string name) => !name.StartsWith(\"$\") || name is \"$file\" or \"$file_json\" or \"$file_csv\";","tryCatchPattern":"try { db.Execute($\"INSERT INTO {target} ...\"); }\ncatch (LiteException ex) when (ex.Message.Contains(\"do not support as output collection\")) {\n    // redirect to a user collection\n}","preventionTips":["Never INSERT INTO read-only system collections.","Use $file variants only for file exports."],"tags":["system-collections","read-only","insert","validation"],"backgroundTag":null,"analyzedSha":"f906a5f850678719e39a39a006cb66dcae563cfa","analyzedAt":"2026-08-13T21:56:30.148Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}