{"record":{"id":"c5d060d1022b9c6b","repo":"invoke-ai/InvokeAI","slug":"default-style-presets-cannot-be-modified","errorCode":null,"errorMessage":"Default style presets cannot be modified","messagePattern":"Default style presets cannot be modified","errorType":"http","errorClass":"HTTPException","httpStatus":403,"severity":"error","filePath":"invokeai/app/api/routers/style_presets.py","lineNumber":62,"sourceCode":"def _assert_preset_read(record: StylePresetRecordDTO, current_user: TokenData) -> None:\n    \"\"\"Allow read access if admin, owner, default preset, or public preset.\"\"\"\n    if current_user.is_admin:\n        return\n    if record.type == PresetType.Default:\n        return\n    if record.is_public:\n        return\n    if record.user_id == current_user.user_id:\n        return\n    raise HTTPException(status_code=403, detail=\"Not authorized to access this style preset\")\n\n\ndef _assert_preset_write(record: StylePresetRecordDTO, current_user: TokenData) -> None:\n    \"\"\"Allow write access only for admin or owner. Defaults are immutable for non-admins.\"\"\"\n    if current_user.is_admin:\n        return\n    if record.type == PresetType.Default:\n        raise HTTPException(status_code=403, detail=\"Default style presets cannot be modified\")\n    if record.user_id == current_user.user_id:\n        return\n    raise HTTPException(status_code=403, detail=\"Not authorized to modify this style preset\")\n\n\ndef _load_record_or_404(style_preset_id: str) -> StylePresetRecordDTO:\n    try:\n        return ApiDependencies.invoker.services.style_preset_records.get(style_preset_id)\n    except StylePresetNotFoundError:\n        raise HTTPException(status_code=404, detail=\"Style preset not found\")\n\n\n@style_presets_router.get(\n    \"/i/{style_preset_id}\",\n    operation_id=\"get_style_preset\",\n    responses={\n        200: {\"model\": StylePresetRecordWithImage},\n    },","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/api/routers/style_presets.py#L44-L80","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Create a copy of the default preset under your own user and modify the copy instead","Have an admin perform the update/delete if changing defaults is genuinely required","Filter out presets with type === 'Default' in any bulk update/delete script","Check preset.type before issuing write calls via GET /style_presets/i/{id}"],"exampleFix":"// before\nfor (const p of presets) {\n  await api.put(`/style_presets/i/${p.id}`, payload); // 403 on defaults\n}\n// after\nfor (const p of presets) {\n  if (p.type === 'Default') continue;\n  await api.put(`/style_presets/i/${p.id}`, payload);\n}","handlingStrategy":"validation","validationCode":"const preset = (await api.get(`/style_presets/i/${id}`)).data;\nif (preset.type === 'Default' && !currentUser.is_admin) {\n  throw new Error('Default presets are immutable for non-admins; create a copy instead');\n}","typeGuard":"function isWritablePreset(preset, user) {\n  if (user.is_admin) return true;\n  return preset.type !== 'Default' && preset.user_id === user.user_id;\n}","tryCatchPattern":"try {\n  await api.put(`/style_presets/i/${id}`, payload);\n} catch (e) {\n  if (e.response?.status === 403) {\n    const preset = (await api.get(`/style_presets/i/${id}`)).data;\n    const copy = await api.post('/style_presets/', { ...payload, name: payload.name + ' (copy)' });\n    return copy.data;\n  }\n  throw e;\n}","preventionTips":["Skip type === 'Default' presets in bulk update/delete scripts","Copy defaults before customizing them","Only admins should alter built-in presets","Filter preset lists client-side to disable edit/delete controls on defaults"],"tags":["http-403","authorization","style-presets","immutable-resource"],"backgroundTag":"insufficient-permissions","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}