{"record":{"id":"6022c3e66f950067","repo":"alibaba/nacos","slug":"invalid-agent-resource-status-status-6022c3","errorCode":null,"errorMessage":"Invalid Agent resource status: {status}","messagePattern":"Invalid Agent resource status: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"api/src/main/java/com/alibaba/nacos/api/ai/utils/AgentModelValidator.java","lineNumber":344,"sourceCode":"        if (provider == null) {\n            return;\n        }\n        validateRequiredLength(provider.getName(), MAX_PROVIDER_NAME_LENGTH, \"provider.name\");\n        if (provider.getUrl() != null) {\n            validateAbsoluteUri(provider.getUrl(), \"provider.url\");\n        }\n    }\n    \n    private static void validateScope(String scope) {\n        if (!\"PUBLIC\".equals(scope) && !\"PRIVATE\".equals(scope)) {\n            throw new IllegalArgumentException(\"scope must be PUBLIC or PRIVATE\");\n        }\n    }\n    \n    private static void validateResourceStatus(String status) {\n        if (!AiConstants.Agent.RESOURCE_STATUS_ENABLE.equals(status)\n            && !AiConstants.Agent.RESOURCE_STATUS_DISABLE.equals(status)) {\n            throw new IllegalArgumentException(\"Invalid Agent resource status: \" + status);\n        }\n    }\n    \n    private static void validateVersionStatus(String status) {\n        if (!AiConstants.Agent.VERSION_STATUS_DRAFT.equals(status)\n            && !AiConstants.Agent.VERSION_STATUS_REVIEWING.equals(status)\n            && !AiConstants.Agent.VERSION_STATUS_REVIEWED.equals(status)\n            && !AiConstants.Agent.VERSION_STATUS_ONLINE.equals(status)\n            && !AiConstants.Agent.VERSION_STATUS_OFFLINE.equals(status)) {\n            throw new IllegalArgumentException(\"Invalid Agent Version status: \" + status);\n        }\n    }\n    \n    private static void validateTags(List<String> tags) {\n        if (tags == null) {\n            return;\n        }\n        if (tags.size() > MAX_TAGS) {","sourceCodeStart":326,"sourceCodeEnd":362,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/api/src/main/java/com/alibaba/nacos/api/ai/utils/AgentModelValidator.java#L326-L362","documentation":"Thrown by the private validateResourceStatus as an IllegalArgumentException when the agent's status field is neither RESOURCE_STATUS_ENABLE nor RESOURCE_STATUS_DISABLE (defined in AiConstants.Agent). Status governs whether the agent resource is active.","triggerScenarios":"Calling validateAgent/validateAgentSummary when agent.getStatus() is null or any value other than the ENABLE/DISABLE constants — e.g. \"ACTIVE\", \"enabled\", \"1\", or a custom lifecycle state.","commonSituations":"A legacy client sent an old status vocabulary; status was left null on create; an external system synced an agent with its own status enum that doesn't map to Nacos values.","solutions":["Map the agent's status to AiConstants.Agent.RESOURCE_STATUS_ENABLE or RESOURCE_STATUS_DISABLE before validation.","Default new agents to ENABLE (or DISABLE) rather than leaving status null.","Normalize incoming status strings to the canonical constants at the integration boundary."],"exampleFix":"// before\nagent.setStatus(\"ACTIVE\");\nAgentModelValidator.validateAgent(agent); // throws\n\n// after\nimport com.alibaba.nacos.api.ai.constant.AiConstants;\nagent.setStatus(AiConstants.Agent.RESOURCE_STATUS_ENABLE);\nAgentModelValidator.validateAgent(agent); // ok","handlingStrategy":"validation","validationCode":"import com.alibaba.nacos.api.ai.constant.AiConstants;\nstatic final Set<String> STATUSES = Set.of(\n    AiConstants.Agent.RESOURCE_STATUS_ENABLE,\n    AiConstants.Agent.RESOURCE_STATUS_DISABLE);\nif (!STATUSES.contains(agent.getStatus())) {\n    agent.setStatus(AiConstants.Agent.RESOURCE_STATUS_DISABLE);\n}\nAgentModelValidator.validateAgent(agent);","typeGuard":"static boolean isValidResourceStatus(String status) {\n    return AiConstants.Agent.RESOURCE_STATUS_ENABLE.equals(status)\n        || AiConstants.Agent.RESOURCE_STATUS_DISABLE.equals(status);\n}","tryCatchPattern":null,"preventionTips":["Always reference AiConstants.Agent status constants rather than string literals.","Map external/legacy status vocabularies to the two canonical values at the integration boundary.","Default new agents to RESOURCE_STATUS_ENABLE or RESOURCE_STATUS_DISABLE explicitly."],"tags":["java","nacos","ai","agents","validation","enum","status"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}