{"record":{"id":"a86af0b34f305bda","repo":"litedb-org/LiteDB","slug":"oldname","errorCode":null,"errorMessage":"oldName","messagePattern":"oldName","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"LiteDB/Client/Database/LiteDatabase.cs","lineNumber":232,"sourceCode":"            return this.GetCollectionNames().Contains(name, StringComparer.OrdinalIgnoreCase);\n        }\n\n        /// <summary>\n        /// Drop a collection and all data + indexes\n        /// </summary>\n        public bool DropCollection(string name)\n        {\n            if (name.IsNullOrWhiteSpace()) throw new ArgumentNullException(nameof(name));\n\n            return _engine.DropCollection(name);\n        }\n\n        /// <summary>\n        /// Rename a collection. Returns false if oldName does not exists or newName already exists\n        /// </summary>\n        public bool RenameCollection(string oldName, string newName)\n        {\n            if (oldName.IsNullOrWhiteSpace()) throw new ArgumentNullException(nameof(oldName));\n            if (newName.IsNullOrWhiteSpace()) throw new ArgumentNullException(nameof(newName));\n\n            return _engine.RenameCollection(oldName, newName);\n        }\n\n        #endregion\n\n        #region Execute SQL\n\n        /// <summary>\n        /// Execute SQL commands and return as data reader.\n        /// </summary>\n        public IBsonDataReader Execute(TextReader commandReader, BsonDocument parameters = null)\n        {\n            if (commandReader == null) throw new ArgumentNullException(nameof(commandReader));\n\n            var tokenizer = new Tokenizer(commandReader);\n            var sql = new SqlParser(_engine, tokenizer, parameters);","sourceCodeStart":214,"sourceCodeEnd":250,"githubUrl":"https://github.com/litedb-org/LiteDB/blob/f906a5f850678719e39a39a006cb66dcae563cfa/LiteDB/Client/Database/LiteDatabase.cs#L214-L250","documentation":"ArgumentNullException thrown by LiteDatabase.RenameCollection(string oldName, string newName) when oldName is null, empty, or whitespace (IsNullOrWhiteSpace check). The source collection name must be concrete to locate it in the catalog before renaming.","triggerScenarios":"Calling db.RenameCollection(null, \"new\") or db.RenameCollection(\"\", \"new\"); a source-name variable that is unset or empty.","commonSituations":"Renaming based on user/config input without validation; swapping argument order so the empty value lands in oldName; leftover placeholder.","solutions":["Pass a concrete non-empty oldName: db.RenameCollection(\"customers\", \"clients\").","Verify oldName is non-empty and ideally exists (CollectionExists) before renaming.","Guard dynamic oldName with IsNullOrWhiteSpace."],"exampleFix":"// before\ndb.RenameCollection(oldName, newName); // oldName may be null\n\n// after\nif (!string.IsNullOrWhiteSpace(oldName) && !string.IsNullOrWhiteSpace(newName))\n{\n    db.RenameCollection(oldName.Trim(), newName.Trim());\n}","handlingStrategy":"validation","validationCode":"if (!string.IsNullOrWhiteSpace(oldName) && db.CollectionExists(oldName.Trim()))\n{\n    // safe to proceed toward rename\n}","typeGuard":"static bool IsValidCollectionName(string name) => !string.IsNullOrWhiteSpace(name);","tryCatchPattern":null,"preventionTips":["Validate oldName is non-empty and exists before renaming.","Keep argument order consistent (oldName, newName) to avoid swap bugs.","Trim names from dynamic sources."],"tags":["collection","argumentnull","validation","renamecollection"],"backgroundTag":null,"analyzedSha":"f906a5f850678719e39a39a006cb66dcae563cfa","analyzedAt":"2026-08-13T21:56:30.148Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}