{"record":{"id":"35489c812602e9e6","repo":"alibaba/nacos","slug":"parameter-missing-35489c","errorCode":"PARAMETER_MISSING","errorMessage":"Required parameter `promptKey` not present","messagePattern":"Required parameter `promptKey` not present","errorType":"validation","errorClass":"NacosApiException","httpStatus":400,"severity":"error","filePath":"ai/src/main/java/com/alibaba/nacos/ai/service/prompt/PromptClientOperationServiceImpl.java","lineNumber":50,"sourceCode":" * Adds MD5-based conditional fetch for SDK client long-polling.</p>\n *\n * @author nacos\n */\n@Service\npublic class PromptClientOperationServiceImpl implements PromptClientOperationService {\n    \n    private final PromptOperationService promptOperationService;\n    \n    public PromptClientOperationServiceImpl(@Lazy PromptOperationService promptOperationService) {\n        this.promptOperationService = promptOperationService;\n    }\n    \n    @Override\n    public PromptVersionInfo queryPrompt(String namespaceId, String promptKey, String version,\n        String label, String md5)\n        throws NacosException {\n        if (StringUtils.isBlank(promptKey)) {\n            throw new NacosApiException(NacosException.INVALID_PARAM, ErrorCode.PARAMETER_MISSING,\n                \"Required parameter `promptKey` not present\");\n        }\n        PromptVersionInfo result =\n            promptOperationService.queryPrompt(namespaceId, promptKey, version, label);\n        String currentMd5 = result.getMd5();\n        if (StringUtils.isNotBlank(md5) && md5.equals(currentMd5)) {\n            throw new NacosException(NacosException.NOT_MODIFIED, \"prompt data is up to date\");\n        }\n        return result;\n    }\n}\n","sourceCodeStart":32,"sourceCodeEnd":62,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/ai/src/main/java/com/alibaba/nacos/ai/service/prompt/PromptClientOperationServiceImpl.java#L32-L62","documentation":"Thrown by PromptClientOperationServiceImpl.queryPrompt (the runtime/client read path used by SDK long-polling) when promptKey is blank. promptKey is the mandatory identifier for a prompt; without it the query cannot be routed. Reported as PARAMETER_MISSING (HTTP 400).","triggerScenarios":"SDK queryPrompt call with promptKey null/empty/whitespace; client binding that failed to populate the key; URL/form parameter stripped by encoding.","commonSituations":"Misconfigured SDK client where the key comes from an empty config property; UI search before a prompt is selected; programmatic loop that passes an uninitialized variable.","solutions":["Always pass a non-blank promptKey to queryPrompt.","Validate the key is set at SDK construction or before the query call.","Default to a known key or fail fast in client code if the source of the key is empty.","Log the inbound parameters at the gateway/controller to detect upstream field loss."],"exampleFix":"// before\npromptClientService.queryPrompt(ns, \"\", ver, label, md5); // 400\n// after\nif (promptKey == null || promptKey.isBlank()) {\n    throw new IllegalArgumentException(\"promptKey is required\");\n}\npromptClientService.queryPrompt(ns, promptKey, ver, label, md5);","handlingStrategy":"validation","validationCode":"// Validate promptKey before the SDK query\nif (promptKey == null || promptKey.isBlank()) {\n    throw new IllegalArgumentException(\"promptKey is required\");\n}\npromptClientService.queryPrompt(namespaceId, promptKey, version, label, md5);","typeGuard":"private static boolean isNotBlank(String s) {\n    return s != null && !s.trim().isEmpty();\n}","tryCatchPattern":"try {\n    result = promptClientService.queryPrompt(ns, key, ver, label, md5);\n} catch (NacosApiException e) {\n    if (e.getErrCode() == ErrorCode.PARAMETER_MISSING.getCode()) {\n        // prompt user to select a prompt key\n    } else { throw e; }\n}","preventionTips":["Set promptKey from a validated config property in the SDK client.","Fail fast at client construction if the key source is empty.","Log inbound parameters at the controller boundary."],"tags":["prompt","parameter-missing","validation","query","sdk","nacos-ai"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}