{"record":{"id":"b5af93187eb0934a","repo":"invoke-ai/InvokeAI","slug":"not-authorized-to-access-this-style-preset","errorCode":null,"errorMessage":"Not authorized to access this style preset","messagePattern":"Not authorized to access this style preset","errorType":"http","errorClass":"HTTPException","httpStatus":403,"severity":"error","filePath":"invokeai/app/api/routers/style_presets.py","lineNumber":54,"sourceCode":"    negative_prompt: str = Field(description=\"Negative prompt\")\n    type: PresetType = Field(description=\"Preset type\")\n    is_public: bool = Field(default=False, description=\"Whether the preset is visible to other users\")\n\n\nstyle_presets_router = APIRouter(prefix=\"/v1/style_presets\", tags=[\"style_presets\"])\n\n\ndef _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\")","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/api/routers/style_presets.py#L36-L72","documentation":"This HTTP 403 is raised by _assert_preset_read when a style preset is not readable by the current user: it is not a Default preset, not marked public, and its user_id does not match the caller's user_id. InvokeAI style presets are private by default; only default, public, or owner-owned presets are readable.","triggerScenarios":"Calling GET /style_presets/i/{style_preset_id} (or fetching its image) for a private preset owned by a different user on a multi-user instance.","commonSituations":"Sharing preset IDs directly with another user instead of marking the preset public; service tokens operating under a different user than the preset owner; referencing presets copied from another account's export.","solutions":["Ask the preset owner to set the preset's access to public, or to export/share the preset file instead of the ID","Access the preset with an admin account or the owning user account","Re-create the preset under your own user from its exported JSON/image","Verify you are authenticated as the user you believe owns the preset (token/user mismatch is common)"],"exampleFix":"// before\nconst preset = await api.get(`/style_presets/i/${sharedId}`); // 403 if private\n// after\ntry {\n  const preset = await api.get(`/style_presets/i/${sharedId}`);\n} catch (e) {\n  if (e.response?.status === 403) {\n    // fall back to importing the shared preset file under own account\n    await importStylePreset(sharedPresetFile);\n    return;\n  }\n  throw e;\n}","handlingStrategy":"validation","validationCode":"const preset = await api.get(`/style_presets/i/${id}`);\nconst { type, is_public, user_id } = preset.data;\nconst readable = type === 'Default' || is_public || user_id === currentUser.id;\nif (!readable) throw new Error('Preset is private and owned by another user');","typeGuard":"function canReadPreset(preset, user) {\n  return preset.type === 'Default' || preset.is_public === true || preset.user_id === user.user_id;\n}","tryCatchPattern":"try {\n  return (await api.get(`/style_presets/i/${id}`)).data;\n} catch (e) {\n  if (e.response?.status === 403) {\n    console.warn('Private preset; import it under your own account instead');\n    return null;\n  }\n  throw e;\n}","preventionTips":["Mark presets public before sharing their IDs across users","Share preset export files instead of raw IDs for private presets","Confirm which user your token represents before accessing foreign presets","Show ownership indicators in UI lists to avoid clicking inaccessible presets"],"tags":["http-403","authorization","style-presets","multi-user"],"backgroundTag":"insufficient-permissions","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}