{"record":{"id":"7f46ce1f72e46e73","repo":"ppy/osu","slug":"failed-to-import-new-beatmap","errorCode":null,"errorMessage":"Failed to import new beatmap","messagePattern":"Failed to import new beatmap","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"osu.Game/Beatmaps/BeatmapManager.cs","lineNumber":136,"sourceCode":"                }\r\n            };\r\n\r\n            var beatmapSet = new BeatmapSetInfo\r\n            {\r\n                DateAdded = DateTimeOffset.UtcNow,\r\n                Beatmaps =\r\n                {\r\n                    new BeatmapInfo(ruleset, new BeatmapDifficulty(), metadata)\r\n                }\r\n            };\r\n\r\n            foreach (BeatmapInfo b in beatmapSet.Beatmaps)\r\n                b.BeatmapSet = beatmapSet;\r\n\r\n            var imported = beatmapImporter.ImportModel(beatmapSet);\r\n\r\n            if (imported == null)\r\n                throw new InvalidOperationException(\"Failed to import new beatmap\");\r\n\r\n            return imported.PerformRead(s => GetWorkingBeatmap(s.Beatmaps.First()));\r\n        }\r\n\r\n        /// <summary>\r\n        /// Add a new difficulty to the provided <paramref name=\"targetBeatmapSet\"/> based on the provided <paramref name=\"referenceWorkingBeatmap\"/>.\r\n        /// The new difficulty will be backed by a <see cref=\"BeatmapInfo\"/> model\r\n        /// and represented by the returned <see cref=\"WorkingBeatmap\"/>.\r\n        /// </summary>\r\n        /// <remarks>\r\n        /// Contrary to <see cref=\"CopyExistingDifficulty\"/>, this method does not preserve hitobjects and beatmap-level settings from <paramref name=\"referenceWorkingBeatmap\"/>.\r\n        /// The created beatmap will have zero hitobjects and will have default settings (including difficulty settings), but will preserve metadata and existing timing points.\r\n        /// </remarks>\r\n        /// <param name=\"targetBeatmapSet\">The <see cref=\"BeatmapSetInfo\"/> to add the new difficulty to.</param>\r\n        /// <param name=\"referenceWorkingBeatmap\">The <see cref=\"WorkingBeatmap\"/> to use as a baseline reference when creating the new difficulty.</param>\r\n        /// <param name=\"rulesetInfo\">The ruleset with which the new difficulty should be created.</param>\r\n        public virtual WorkingBeatmap CreateNewDifficulty(BeatmapSetInfo targetBeatmapSet, WorkingBeatmap referenceWorkingBeatmap, RulesetInfo rulesetInfo)\r\n        {\r","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/ppy/osu/blob/d9c73e12adff2feaae4a3e158d36fe5883faf6ca/osu.Game/Beatmaps/BeatmapManager.cs#L118-L154","documentation":"Thrown by BeatmapManager.Save/Import when beatmapImporter.ImportModel returns null, meaning the beatmap set failed to persist. ImportModel returning null typically signals that the model was rejected during the realm write — either a duplicate was found and merged silently but the merged result couldn't be returned, or the import transaction encountered an internal failure.","triggerScenarios":"Calling BeatmapManager.Import with a programmatically-constructed BeatmapSetInfo where ImportModel returns null — the model may violate a uniqueness constraint, or the underlying RealmArchiveModelImporter rejected it during the import transaction.","commonSituations":"Programmatically creating a BeatmapSetInfo and importing it without all required fields populated; importing a beatmap set that already exists and the dedup logic returns null instead of the existing entry; a Realm/database issue during the write transaction (locked realm, schema mismatch).","solutions":["Check the import logs for the underlying reason ImportModel returned null — often a duplicate detection or realm error is logged just before the null return.","Ensure the BeatmapSetInfo being imported has all required fields (Beatmaps list with valid BeatmapInfo, metadata, ruleset, hashes).","If importing a beatmap that may already exist, call GetExistingBeatmapSet or check for duplicates before importing.","Verify the Realm database isn't locked or in a migration-required state by checking realm access logs."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try\n{\n    var working = beatmapManager.Import(beatmapSet);\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"Failed to import new beatmap\"))\n{\n    Logger.Log($\"Import failed — check realm/database state and for duplicates\", LoggingTarget.Database);\n    // fall back to user-facing error or retry after dedup\n}","preventionTips":["Populate all required fields on BeatmapSetInfo before importing (Beatmaps, metadata, ruleset, hashes).","Check for existing beatmap sets to avoid duplicate-import conflicts.","Monitor realm/database health and migration status before import operations."],"tags":["beatmap-import","realm","persistence","database"],"backgroundTag":null,"analyzedSha":"d9c73e12adff2feaae4a3e158d36fe5883faf6ca","analyzedAt":"2026-08-13T14:12:54.015Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}