invoke-ai/InvokeAI · error · HTTPException

Default style presets cannot be modified

Error message

Default style presets cannot be modified

What it means

This HTTP 403 is raised by _assert_preset_write for non-admin users attempting to update or delete a preset whose type is PresetType.Default. Default style presets ship with InvokeAI and are immutable for regular users by design; only admins may modify or remove them.

Source

Thrown at invokeai/app/api/routers/style_presets.py:62

def _assert_preset_read(record: StylePresetRecordDTO, current_user: TokenData) -> None:
    """Allow read access if admin, owner, default preset, or public preset."""
    if current_user.is_admin:
        return
    if record.type == PresetType.Default:
        return
    if record.is_public:
        return
    if record.user_id == current_user.user_id:
        return
    raise HTTPException(status_code=403, detail="Not authorized to access this style preset")


def _assert_preset_write(record: StylePresetRecordDTO, current_user: TokenData) -> None:
    """Allow write access only for admin or owner. Defaults are immutable for non-admins."""
    if current_user.is_admin:
        return
    if record.type == PresetType.Default:
        raise HTTPException(status_code=403, detail="Default style presets cannot be modified")
    if record.user_id == current_user.user_id:
        return
    raise HTTPException(status_code=403, detail="Not authorized to modify this style preset")


def _load_record_or_404(style_preset_id: str) -> StylePresetRecordDTO:
    try:
        return ApiDependencies.invoker.services.style_preset_records.get(style_preset_id)
    except StylePresetNotFoundError:
        raise HTTPException(status_code=404, detail="Style preset not found")


@style_presets_router.get(
    "/i/{style_preset_id}",
    operation_id="get_style_preset",
    responses={
        200: {"model": StylePresetRecordWithImage},
    },

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Create a copy of the default preset under your own user and modify the copy instead
  2. Have an admin perform the update/delete if changing defaults is genuinely required
  3. Filter out presets with type === 'Default' in any bulk update/delete script
  4. Check preset.type before issuing write calls via GET /style_presets/i/{id}

Example fix

// before
for (const p of presets) {
  await api.put(`/style_presets/i/${p.id}`, payload); // 403 on defaults
}
// after
for (const p of presets) {
  if (p.type === 'Default') continue;
  await api.put(`/style_presets/i/${p.id}`, payload);
}
Defensive patterns

Strategy: validation

Validate before calling

const preset = (await api.get(`/style_presets/i/${id}`)).data;
if (preset.type === 'Default' && !currentUser.is_admin) {
  throw new Error('Default presets are immutable for non-admins; create a copy instead');
}

Type guard

function isWritablePreset(preset, user) {
  if (user.is_admin) return true;
  return preset.type !== 'Default' && preset.user_id === user.user_id;
}

Try / catch

try {
  await api.put(`/style_presets/i/${id}`, payload);
} catch (e) {
  if (e.response?.status === 403) {
    const preset = (await api.get(`/style_presets/i/${id}`)).data;
    const copy = await api.post('/style_presets/', { ...payload, name: payload.name + ' (copy)' });
    return copy.data;
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling PUT/DELETE on /style_presets/i/{style_preset_id} where the target is a built-in Default preset and the token is not admin.

Common situations: Users trying to 'fix' or rename a built-in preset in the UI or via API; scripts iterating over all presets and deleting/updating them blindly; automated cleanup jobs that don't filter by preset type.

Related errors


AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29). Data as JSON: /api/errors/c5d060d1022b9c6b. Report an issue: GitHub.