langgenius/dify · error · ValueError
Invalid status
Error message
Invalid status
What it means
ValueError('Invalid status') raised in AppMCPServer update handler when req_data.status cannot be coerced into the AppMCPServerStatus enum. The enum (api/models/enums.py:96) only accepts 'normal', 'active', 'inactive'. Flask returns this as a 400.
Source
Thrown at api/controllers/console/app/mcp_server.py:176
.limit(1)
)
if not server:
raise NotFound()
description = req_data.description
if description is None or not description:
server.description = app_model.description or ""
else:
server.description = description
server.name = app_model.name
server.parameters = json.dumps(req_data.parameters, ensure_ascii=False)
if req_data.status:
try:
server.status = AppMCPServerStatus(req_data.status)
except ValueError:
raise ValueError("Invalid status")
db.session.commit()
return dump_response(AppMCPServerResponse, server)
@console_ns.route("/apps/<uuid:app_id>/server/refresh")
class AppMCPServerRefreshController(Resource):
@console_ns.doc("refresh_app_mcp_server")
@console_ns.doc(description="Refresh MCP server configuration and regenerate server code")
@console_ns.doc(params={"app_id": "App ID"})
@console_ns.response(200, "MCP server refreshed successfully", console_ns.models[AppMCPServerResponse.__name__])
@console_ns.response(403, "Insufficient permissions")
@console_ns.response(404, "Server not found")
@setup_required
@login_required
@account_initialization_required
@edit_permission_required
@rbac_permission_required(RBACResourceScope.APP, RBACPermission.APP_VIEW_LAYOUT)
@with_current_tenant_idView on GitHub (pinned to ef8544b173)
Solutions
- Send status as one of 'normal', 'active', or 'inactive'.
- If you need a new status, add it to AppMCPServerStatus in api/models/enums.py and update any consumers.
- Constrain the client UI to a dropdown of the three valid values.
Example fix
// before
{ "status": "enabled" }
// after
{ "status": "active" } Defensive patterns
Strategy: type-guard
Validate before calling
const VALID_STATUSES = new Set(['normal', 'active', 'inactive']);
function isValidServerStatus(s: string): boolean {
return VALID_STATUSES.has(s);
}
if (!isValidServerStatus(payload.status)) {
throw new Error(`status must be one of normal|active|inactive, got ${payload.status}`);
} Type guard
type AppMCPServerStatus = 'normal' | 'active' | 'inactive';
function isAppMCPServerStatus(s: string): s is AppMCPServerStatus {
return s === 'normal' || s === 'active' || s === 'inactive';
} Prevention
- Bind the status field to a dropdown of the three enum values.
- Validate against AppMCPServerStatus client-side before PUT/PATCH.
- When adding a status, update the enum and all clients together.
When it happens
Trigger: PUT/PATCH on /console/api/apps/<app_id>/server with a status field that is not one of 'normal', 'active', 'inactive' (e.g. 'running', 'enabled', 'paused', empty string).
Common situations: Client guessing status values; frontend regression sending a stale enum; integration passing an unrelated status vocabulary.
Related errors
- unsupported argument value
- metadata must be one of all, only, without
- rating must be either 'like' or 'dislike'
- Invalid type: {req_data.type}
- streaming response body missing
AI-assisted analysis of langgenius/dify@ef8544b173 (2026-08-12).
Data as JSON: /api/errors/22161d3f91958d24.
Report an issue: GitHub.