{"record":{"id":"12fd3c106fb7fdf9","repo":"gildas-lormeau/SingleFile","slug":"default-settings-cannot-be-renamed","errorCode":null,"errorMessage":"Default settings cannot be renamed","messagePattern":"Default settings cannot be renamed","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/core/bg/config.js","lineNumber":604,"sourceCode":"\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}\n\tif (oldProfileName == DEFAULT_PROFILE_NAME) {\n\t\tthrow new Error(\"Default settings cannot be renamed\");\n\t}\n\tif (allTabsData.profileName == oldProfileName) {\n\t\tallTabsData.profileName = profileName;\n\t\tawait tabsData.set(allTabsData);\n\t}\n\trules.forEach(rule => {\n\t\tif (rule.profile == oldProfileName) {\n\t\t\trule.profile = profileName;\n\t\t}\n\t\tif (rule.autoSaveProfile == oldProfileName) {\n\t\t\trule.autoSaveProfile = profileName;\n\t\t}\n\t});\n\tconst profile = await getProfile(oldProfileName);\n\tawait configStorage.remove([PROFILE_NAME_PREFIX + oldProfileName]);\n\tawait configStorage.set({ [PROFILE_NAME_PREFIX + profileName]: profile, rules });\n}\n","sourceCodeStart":586,"sourceCodeEnd":622,"githubUrl":"https://github.com/gildas-lormeau/SingleFile/blob/517fb7c5cf2096d89933b747e862d8ecf616a9f9/src/core/bg/config.js#L586-L622","documentation":"Thrown by renameProfile(oldProfileName, profileName) in src/core/bg/config.js:604 when an attempt is made to rename the built-in default profile (DEFAULT_PROFILE_NAME, e.g. \"Default settings\"). The default profile is fixed by design; callers should disallow rename operations on it in the UI and only permit renaming user-created profiles.","triggerScenarios":"renameProfile(DEFAULT_PROFILE_NAME, newName) called with the default profile name as the source — from UI misuse or scripts iterating all profiles and renaming each.","commonSituations":"Bulk rename scripts that don't skip the default profile; automation treating default like a normal profile; UI allowing rename on the default row by mistake.","solutions":["Skip the default profile in rename loops (check against the default profile name before renaming)","Only allow rename actions on user-created profiles in UI code","Catch the error and ignore it for the default profile","Create a copy under a new name instead of renaming the default"],"exampleFix":"// before\nfor (const name of names) await config.renameProfile(name, name + '-old');\n// after\nfor (const name of names) {\n  if (name === 'default') continue; // skip default profile\n  await config.renameProfile(name, name + '-old');\n}","handlingStrategy":"validation","validationCode":"// default profile name per config.DEFAULT_PROFILE_NAME (e.g. 'default')\nif (oldProfileName === 'default') throw new Skip();","typeGuard":"const isDefaultProfile = (n) => n === config.DEFAULT_PROFILE_NAME;","tryCatchPattern":"try { await renameProfile(name, newName); } catch (e) { if (e.message === 'Default settings cannot be renamed') return; throw e; }","preventionTips":["Exclude the default profile from rename UI/actions","Skip DEFAULT_PROFILE_NAME in bulk rename scripts","Expose rename only for user-created profiles","Create a new profile rather than renaming the default"],"tags":["configuration","profile","protected-resource"],"backgroundTag":"protected-profile-modification","analyzedSha":"517fb7c5cf2096d89933b747e862d8ecf616a9f9","analyzedAt":"2026-09-01T10:05:25.770Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}