{"record":{"id":"596382a9da1ff426","repo":"alibaba/nacos","slug":"invalid-param-596382","errorCode":"INVALID_PARAM","errorMessage":"Required parameter `promptKey` not present","messagePattern":"Required parameter `promptKey` not present","errorType":"validation","errorClass":"NacosException","httpStatus":null,"severity":"error","filePath":"client/src/main/java/com/alibaba/nacos/client/ai/cache/NacosPromptCacheHolder.java","lineNumber":90,"sourceCode":"        return queryPrompt(promptKey, version, label, null);\n    }\n    \n    private Prompt queryPrompt(String promptKey, String version, String label, String md5)\n        throws NacosException {\n        return aiClientProxy.queryPrompt(promptKey, version, label, md5);\n    }\n    \n    /**\n     * Subscribe prompt and start polling for prompt changes.\n     *\n     * @param promptKey prompt key\n     * @return current Prompt object, null if not found\n     * @throws NacosException if error occurs\n     */\n    public Prompt subscribePrompt(String promptKey, String version, String label)\n        throws NacosException {\n        if (StringUtils.isBlank(promptKey)) {\n            throw new NacosException(NacosException.INVALID_PARAM,\n                \"Required parameter `promptKey` not present\");\n        }\n        String cacheKey = CacheKeyUtils.buildPromptKey(promptKey, version, label);\n        \n        Prompt prompt = null;\n        try {\n            prompt = queryPrompt(promptKey, version, label);\n            processPrompt(promptKey, cacheKey, prompt);\n        } catch (NacosException e) {\n            if (e.getErrCode() != NacosException.NOT_FOUND) {\n                throw e;\n            }\n            processPrompt(promptKey, cacheKey, null);\n        }\n        addPromptUpdateTask(promptKey, version, label);\n        LOGGER.info(\"Subscribed prompt: {}, version: {}, label: {}\", promptKey, version, label);\n        return prompt;\n    }","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/client/src/main/java/com/alibaba/nacos/client/ai/cache/NacosPromptCacheHolder.java#L72-L108","documentation":"Thrown by NacosPromptCacheHolder.subscribePrompt when promptKey is blank. subscribePrompt performs the initial query synchronously, primes the cache, then polls for prompt changes keyed on the prompt key (plus version/label). An empty key cannot identify the prompt resource, so the guard rejects it as INVALID_PARAM before the proxy call.","triggerScenarios":"Calling subscribePrompt(null, ...), subscribePrompt(\"\", ...) or with a whitespace-only promptKey. version and label are optional but the key is mandatory.","commonSituations":"Prompt key read from config/ENV that was not set; key parsed from an incoming request whose promptKey field was omitted; test subscribe with an uninitialized key field.","solutions":["Validate promptKey is non-blank before calling subscribePrompt.","Make promptKey a required field wherever prompts are referenced and fail fast if missing.","Pass version/label as optional only after confirming the key is present."],"exampleFix":"// before\ncache.subscribePrompt(promptKey, version, label);\n// after\nif (StringUtils.isBlank(promptKey)) {\n    throw new IllegalArgumentException(\"promptKey is required\");\n}\ncache.subscribePrompt(promptKey, version, label);","handlingStrategy":"validation","validationCode":"if (StringUtils.isBlank(promptKey)) {\n    throw new IllegalArgumentException(\"promptKey is required\");\n}\ncache.subscribePrompt(promptKey, version, label);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat promptKey as mandatory; version/label are the only optional parts.","Validate request DTOs carrying prompt subscriptions for a non-blank key.","Fail fast on empty config-derived keys."],"tags":["ai","prompt","subscription","validation","invalid-param"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}