gildas-lormeau/SingleFile · error · Error

Default settings cannot be deleted

Error message

Default settings cannot be deleted

What it means

deleteProfile refuses to delete the built-in default profile (DEFAULT_PROFILE_NAME). The default profile is a permanent baseline configuration ('Default settings') used whenever no other profile applies, so the library intentionally makes it undeletable. Any deleteProfile call targeting it throws this error before any storage mutation occurs.

Source

Thrown at src/core/bg/config.js:631

		}
		if (rule.autoSaveProfile == oldProfileName) {
			rule.autoSaveProfile = profileName;
		}
	});
	const profile = await getProfile(oldProfileName);
	await configStorage.remove([PROFILE_NAME_PREFIX + oldProfileName]);
	await configStorage.set({ [PROFILE_NAME_PREFIX + profileName]: profile, rules });
}

async function deleteProfile(profileName) {
	const profileNames = await getProfileNames();
	const allTabsData = await tabsData.get();
	const rules = await getRules();
	if (!profileNames.includes(profileName)) {
		throw new Error("Profile not found");
	}
	if (profileName == DEFAULT_PROFILE_NAME) {
		throw new Error("Default settings cannot be deleted");
	}
	if (allTabsData.profileName == profileName) {
		delete allTabsData.profileName;
		await tabsData.set(allTabsData);
	}
	rules.forEach(rule => {
		if (rule.profile == profileName) {
			rule.profile = DEFAULT_PROFILE_NAME;
		}
		if (rule.autoSaveProfile == profileName) {
			rule.autoSaveProfile = DEFAULT_PROFILE_NAME;
		}
	});
	configStorage.remove([PROFILE_NAME_PREFIX + profileName]);
	await configStorage.set({ rules });
}

async function getRules() {

View on GitHub (pinned to 517fb7c5cf)

Solutions

  1. Guard the call: if (profileName === DEFAULT_PROFILE_NAME) skip or disable the delete action in the UI.
  2. Filter the default profile out of bulk-delete loops: for (const name of names.filter(n => n !== DEFAULT_PROFILE_NAME)) await deleteProfile(name);
  3. If the intent is to restore defaults, call resetProfile(DEFAULT_PROFILE_NAME) instead of deleting.

Example fix

// before
for (const name of await getProfileNames()) await deleteProfile(name);
// after
for (const name of (await getProfileNames()).filter(n => n !== DEFAULT_PROFILE_NAME)) await deleteProfile(name);
Defensive patterns

Strategy: validation

Validate before calling

if (profileName === DEFAULT_PROFILE_NAME) return; // skip delete
await deleteProfile(profileName);

Type guard

const isDefaultProfile = (name) => typeof name === 'string' && name === DEFAULT_PROFILE_NAME;

Try / catch

try { await deleteProfile(name); } catch (e) { if (e.message === 'Default settings cannot be deleted') { /* disable UI control */ } else throw e; }

Prevention

When it happens

Trigger: Calling deleteProfile(profileName) from the extension message handler (onMessage) with profileName equal to DEFAULT_PROFILE_NAME; e.g. a UI 'delete' action on the default settings entry.

Common situations: Rendering delete buttons for every profile in a settings page including the default one; programmatic cleanup that iterates all getProfileNames() results and deletes each without filtering out the default.

Related errors


AI-assisted analysis of gildas-lormeau/SingleFile@517fb7c5cf (2026-09-01). Data as JSON: /api/errors/32a4d1e091d5fa88. Report an issue: GitHub.