{"record":{"id":"334186dc27a5697c","repo":"JosefNemec/Playnite","slug":"assigned-custom-emulator-profile-not-found","errorCode":null,"errorMessage":"Assigned custom emulator profile not found.","messagePattern":"Assigned custom emulator profile not found\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"source/Playnite/Emulators/Scanner.cs","lineNumber":224,"sourceCode":"            importedFiles = database.GetImportedRomFiles(emulator.InstallDir);\r\n            var globalScanConfig = database.GetGameScannersSettings();\r\n            var crcExclusions = string.Join(\";\",\r\n                ListExtensions.Merge(globalScanConfig.CrcExcludeFileTypes, scanner.CrcExcludeFileTypes).\r\n                Select(a => a.ToLower().Trim()).ToHashSet());\r\n            var dirToScan = PlaynitePaths.ExpandVariables(scanner.Directory, emulator.InstallDir, true);\r\n\r\n            fileExclusions = ParseExclusions(dirToScan, scanner.ExcludedFiles);\r\n            directoryExclusions = ParseExclusions(dirToScan, scanner.ExcludedDirectories);\r\n\r\n            CustomEmulatorProfile customProfile = null;\r\n            BuiltInEmulatorProfile builtinProfile = null;\r\n            EmulatorDefinitionProfile builtinProfileDef = null;\r\n            if (scanner.EmulatorProfileId.StartsWith(CustomEmulatorProfile.ProfilePrefix, StringComparison.Ordinal))\r\n            {\r\n                customProfile = emulator.CustomProfiles?.FirstOrDefault(a => a.Id == scanner.EmulatorProfileId);\r\n                if (customProfile == null)\r\n                {\r\n                    throw new Exception(\"Assigned custom emulator profile not found.\");\r\n                }\r\n\r\n                games = ScanDirectory(\r\n                    dirToScan,\r\n                    emulator,\r\n                    customProfile,\r\n                    cancelToken,\r\n                    crcExclusions,\r\n                    scanner.ScanSubfolders,\r\n                    scanner.ScanInsideArchives,\r\n                    scanner.MergeRelatedFiles,\r\n                    fileScanCallback);\r\n            }\r\n            else if (scanner.EmulatorProfileId.StartsWith(BuiltInEmulatorProfile.ProfilePrefix, StringComparison.Ordinal))\r\n            {\r\n                builtinProfile = emulator.BuiltinProfiles?.FirstOrDefault(a => a.Id == scanner.EmulatorProfileId);\r\n                if (builtinProfile == null)\r\n                {\r","sourceCodeStart":206,"sourceCodeEnd":242,"githubUrl":"https://github.com/JosefNemec/Playnite/blob/5911f4e964e628aa7a69c2030ab35101afa63067/source/Playnite/Emulators/Scanner.cs#L206-L242","documentation":"Thrown as a generic Exception during emulator-based ROM scanning when the EmulatorProfileId starts with the CustomEmulatorProfile.ProfilePrefix (indicating it should be a custom profile) but no matching profile is found in emulator.CustomProfiles. The scanner references a specific custom emulator profile by ID that either was deleted or never existed for this emulator.","triggerScenarios":"scanner.EmulatorProfileId starts with CustomEmulatorProfile.ProfilePrefix and a FirstOrDefault lookup against emulator.CustomProfiles returns null. The profile ID is well-formed (correct prefix) but the profile record itself is missing from the emulator's CustomProfiles collection.","commonSituations":"The custom emulator profile was deleted by the user but the scanner still references its ID. The scanner was imported from another database where the profile existed. A database sync or migration lost the CustomProfiles entry. The profile ID was typed or set programmatically with a value that doesn't match any stored profile.","solutions":["Open the scanner configuration and re-select the custom emulator profile from the dropdown.","If the profile was deleted, recreate it with the same settings and update the scanner to reference the new profile.","Verify the emulator's CustomProfiles collection contains the expected profile: check emulator settings in Playnite.","Delete the stale scanner and recreate it with valid references."],"exampleFix":"// before — scanner references a deleted custom profile\nscanner.EmulatorProfileId = \"custom-abc123\"; // profile no longer exists\nRunScan(scanner); // throws\n\n// after — validate profile existence before scanning\nvar profile = emulator.CustomProfiles?.FirstOrDefault(p => p.Id == scanner.EmulatorProfileId);\nif (profile == null)\n{\n    logger.Warn($\"Custom profile {scanner.EmulatorProfileId} not found; please reconfigure scanner.\");\n    return;\n}\nRunScan(scanner);","handlingStrategy":"validation","validationCode":"var customProfile = emulator.CustomProfiles?.FirstOrDefault(p => p.Id == scanner.EmulatorProfileId);\nif (customProfile == null)\n{\n    logger.Warn($\"Custom profile {scanner.EmulatorProfileId} not found on emulator {emulator.Name}.\");\n    continue;\n}","typeGuard":"static bool CustomProfileExists(Emulator emulator, string profileId)\n{\n    return emulator.CustomProfiles?.Any(p => p.Id == profileId) == true;\n}","tryCatchPattern":null,"preventionTips":["When deleting a custom emulator profile, remove or update dependent scanners.","Validate scanner profile references before running scans.","Provide a UI indicator for scanners with broken profile references."],"tags":["emulator","scanner","rom-import","stale-reference","emulator-profile","custom-profile"],"backgroundTag":null,"analyzedSha":"5911f4e964e628aa7a69c2030ab35101afa63067","analyzedAt":"2026-08-13T17:38:25.713Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}