{"record":{"id":"980fe3c18a8a4e58","repo":"gildas-lormeau/SingleFile","slug":"profile-not-found","errorCode":null,"errorMessage":"Profile not found","messagePattern":"Profile not found","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/core/bg/config.js","lineNumber":584,"sourceCode":"\tlet selectedProfileName;\n\tif (rule) {\n\t\tconst profileName = rule[autoSave ? \"autoSaveProfile\" : \"profile\"];\n\t\tselectedProfileName = profileName == CURRENT_PROFILE_NAME ? tabProfileName : profileName;\n\t} else {\n\t\tselectedProfileName = tabProfileName;\n\t}\n\tconst profile = await getProfile(selectedProfileName);\n\tconst options = Object.assign({ profileName: selectedProfileName }, profile);\n\tif (!BACKGROUND_SAVE_SUPPORTED) {\n\t\toptions.backgroundSave = false;\n\t}\n\treturn options;\n}\n\nasync function updateProfile(profileName, profile) {\n\tconst profileNames = await getProfileNames();\n\tif (!profileNames.includes(profileName)) {\n\t\tthrow new Error(\"Profile not found\");\n\t}\n\tconst previousProfile = await getProfile(profileName);\n\tObject.keys(previousProfile).forEach(key => {\n\t\tprofile[key] = profile[key] === undefined ? previousProfile[key] : profile[key];\n\t});\n\tawait setProfile(profileName, profile);\n}\n\nasync function renameProfile(oldProfileName, profileName) {\n\tconst profileNames = await getProfileNames();\n\tconst allTabsData = await tabsData.get();\n\tconst rules = await getRules();\n\tif (!profileNames.includes(oldProfileName)) {\n\t\tthrow new Error(\"Profile not found\");\n\t}\n\tif (profileNames.includes(profileName)) {\n\t\tthrow new Error(\"Duplicate profile name\");\n\t}","sourceCodeStart":566,"sourceCodeEnd":602,"githubUrl":"https://github.com/gildas-lormeau/SingleFile/blob/517fb7c5cf2096d89933b747e862d8ecf616a9f9/src/core/bg/config.js#L566-L602","documentation":"Thrown by updateProfile(profileName, profile) in src/core/bg/config.js:584 when the given profileName does not exist in the list of stored profile names. It is a guard against updating a profile that has been deleted or was never created; callers should verify the profile name (e.g. via getProfileNames) before attempting an update, and surface a user-facing error prompting them to pick an existing profile.","triggerScenarios":"updateProfile(name, profile) called for a name never created, or one that was deleted/renamed before the update — often via onMessage from a stale UI state.","commonSituations":"Options page kept open while the profile was deleted in another tab; renaming a profile then applying saved edits under the old name; typos in programmatic profile names; storage cleared between calls.","solutions":["Confirm the profile exists with getProfileNames() before updating","Recreate the profile if it was deleted, then re-apply the update","Refresh the UI's profile list after any create/rename/delete to avoid stale names","Catch the error and fall back to createProfile if creating is acceptable"],"exampleFix":"// before\nawait config.updateProfile('work', partial);\n// after\nconst names = await config.getProfileNames();\nif (!names.includes('work')) await config.createProfile('work', 'default');\nawait config.updateProfile('work', partial);","handlingStrategy":"validation","validationCode":"const names = await config.getProfileNames();\nif (!names.includes(profileName)) await config.createProfile(profileName, 'default');","typeGuard":"const profileExists = async (n) => (await config.getProfileNames()).includes(n);","tryCatchPattern":"try { await updateProfile(name, profile); } catch (e) { if (e.message === 'Profile not found') await recreateAndApply(name, profile); else throw e; }","preventionTips":["Refresh profile lists after any create/rename/delete","Don't cache profile names across long-lived UI sessions","Create-before-update when existence is uncertain","Validate names against the live list, not stored copies"],"tags":["configuration","profile","not-found"],"backgroundTag":"profile-not-found","analyzedSha":"517fb7c5cf2096d89933b747e862d8ecf616a9f9","analyzedAt":"2026-09-01T10:05:25.770Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}