invoke-ai/InvokeAI · error · HTTPException
Only admins can create default presets
Error message
Only admins can create default presets
What it means
After validating the form data, create_style_preset rejects non-admin users who attempt to create a preset with type PresetType.Default, returning HTTP 403 'Only admins can create default presets'. Default presets are the shipped catalog and are admin-managed by design.
Source
Thrown at invokeai/app/api/routers/style_presets.py:212
) -> StylePresetRecordWithImage:
"""Creates a style preset"""
try:
parsed_data = json.loads(data)
validated_data = StylePresetFormData(**parsed_data)
name = validated_data.name
type = validated_data.type
positive_prompt = validated_data.positive_prompt
negative_prompt = validated_data.negative_prompt
is_public = validated_data.is_public
except (json.JSONDecodeError, pydantic.ValidationError):
raise HTTPException(status_code=400, detail="Invalid preset data")
# Only admins may create default-typed presets — they're the shipped catalog.
if type == PresetType.Default and not current_user.is_admin:
raise HTTPException(status_code=403, detail="Only admins can create default presets")
pil_image = None
if image is not None:
if not image.content_type or not image.content_type.startswith("image"):
raise HTTPException(status_code=415, detail="Not an image")
contents = await image.read()
try:
pil_image = await asyncio.to_thread(Image.open, io.BytesIO(contents))
except Exception:
ApiDependencies.invoker.services.logger.error(traceback.format_exc())
raise HTTPException(status_code=415, detail="Failed to read image")
preset_data = PresetData(positive_prompt=positive_prompt, negative_prompt=negative_prompt)
style_preset = StylePresetWithoutId(name=name, preset_data=preset_data, type=type, is_public=is_public)
new_style_preset = await asyncio.to_thread(
ApiDependencies.invoker.services.style_preset_records.create,View on GitHub (pinned to 0b6a024f2f)
Solutions
- Change the preset type in the data payload to 'user' (or another non-default PresetType).
- If a default preset is genuinely needed, have an admin account create it, or ask an admin to grant the account admin rights.
- Fix the client UI so new presets default to type 'user'.
- When duplicating a default preset, strip/replace the type field before POSTing.
Example fix
// before
const preset = { ...copiedDefault, name: "Mine" }; // type: "default"
// after
const preset = { ...copiedDefault, name: "Mine", type: "user" }; Defensive patterns
Strategy: validation
Validate before calling
function assertCanCreateType(presetType, currentUser) {
if (presetType === "default" && !currentUser.is_admin) {
throw new Error("Only admins can create default presets");
}
}
assertCanCreateType(preset.type, currentUser); // before POST /style_presets/ Type guard
function isAdminUser(u: { is_admin?: boolean }): u is { is_admin: true } {
return u.is_admin === true;
} Try / catch
try {
return await api.createStylePreset({ data: JSON.stringify(preset), image });
} catch (e) {
if (e.status === 403 && e.detail === "Only admins can create default presets") {
// non-admin: coerce to 'user' type or prompt for admin elevation
return api.createStylePreset({ data: JSON.stringify({ ...preset, type: "user" }), image });
} else throw e;
} Prevention
- Never send type 'default' unless the account is verified admin.
- Hide/lock the default-type option for non-admin users in the UI.
- When cloning a shipped preset, always rewrite type to 'user'.
- Check the current user's role from the API before offering admin-only operations.
When it happens
Trigger: POST /style_presets/ with data JSON containing "type": "default" (PresetType.Default) while the authenticated user's is_admin is false.
Common situations: Client UI defaulting the type dropdown to 'default'; copying a shipped default preset's JSON as a template and forgetting to change its type; non-admin service accounts automating imports; user account lacking admin role after an instance migration.
Related errors
- Not authorized to modify this board
- Not authorized to access this system prompt
- Not authorized to update this system prompt
- Not authorized to delete this system prompt
- Not authorized to modify this video
AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29).
Data as JSON: /api/errors/ec4d605b42be4329.
Report an issue: GitHub.