{"record":{"id":"22161d3f91958d24","repo":"langgenius/dify","slug":"invalid-status","errorCode":null,"errorMessage":"Invalid status","messagePattern":"Invalid status","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"api/controllers/console/app/mcp_server.py","lineNumber":176,"sourceCode":"            .limit(1)\n        )\n        if not server:\n            raise NotFound()\n\n        description = req_data.description\n        if description is None or not description:\n            server.description = app_model.description or \"\"\n        else:\n            server.description = description\n\n        server.name = app_model.name\n\n        server.parameters = json.dumps(req_data.parameters, ensure_ascii=False)\n        if req_data.status:\n            try:\n                server.status = AppMCPServerStatus(req_data.status)\n            except ValueError:\n                raise ValueError(\"Invalid status\")\n        db.session.commit()\n        return dump_response(AppMCPServerResponse, server)\n\n\n@console_ns.route(\"/apps/<uuid:app_id>/server/refresh\")\nclass AppMCPServerRefreshController(Resource):\n    @console_ns.doc(\"refresh_app_mcp_server\")\n    @console_ns.doc(description=\"Refresh MCP server configuration and regenerate server code\")\n    @console_ns.doc(params={\"app_id\": \"App ID\"})\n    @console_ns.response(200, \"MCP server refreshed successfully\", console_ns.models[AppMCPServerResponse.__name__])\n    @console_ns.response(403, \"Insufficient permissions\")\n    @console_ns.response(404, \"Server not found\")\n    @setup_required\n    @login_required\n    @account_initialization_required\n    @edit_permission_required\n    @rbac_permission_required(RBACResourceScope.APP, RBACPermission.APP_VIEW_LAYOUT)\n    @with_current_tenant_id","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/api/controllers/console/app/mcp_server.py#L158-L194","documentation":"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.","triggerScenarios":"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).","commonSituations":"Client guessing status values; frontend regression sending a stale enum; integration passing an unrelated status vocabulary.","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."],"exampleFix":"// before\n{ \"status\": \"enabled\" }\n// after\n{ \"status\": \"active\" }","handlingStrategy":"type-guard","validationCode":"const VALID_STATUSES = new Set(['normal', 'active', 'inactive']);\nfunction isValidServerStatus(s: string): boolean {\n  return VALID_STATUSES.has(s);\n}\nif (!isValidServerStatus(payload.status)) {\n  throw new Error(`status must be one of normal|active|inactive, got ${payload.status}`);\n}","typeGuard":"type AppMCPServerStatus = 'normal' | 'active' | 'inactive';\nfunction isAppMCPServerStatus(s: string): s is AppMCPServerStatus {\n  return s === 'normal' || s === 'active' || s === 'inactive';\n}","tryCatchPattern":null,"preventionTips":["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."],"tags":["validation","enum","mcp-server","status","strenum"],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}