{"record":{"id":"57bab603de7298d9","repo":"alibaba/nacos","slug":"30000","errorCode":"30000","errorMessage":"Meta version missing","messagePattern":"Meta version missing","errorType":"exception","errorClass":"NacosApiException","httpStatus":500,"severity":"critical","filePath":"ai/src/main/java/com/alibaba/nacos/ai/service/prompt/PromptOperationServiceImpl.java","lineNumber":927,"sourceCode":"        if (StringUtils.isBlank(json)) {\n            return null;\n        }\n        try {\n            return JacksonUtils.toObj(json, PromptVersionInfoPojo.class);\n        } catch (Exception e) {\n            return null;\n        }\n    }\n    \n    private void updateMetaBizTagsCas(String namespaceId, AiResource meta, String bizTags)\n        throws NacosException {\n        resourceManager.updateBizTagsCas(namespaceId, meta, bizTags);\n    }\n    \n    private void updateMetaDescriptionCas(String namespaceId, AiResource meta, String description)\n        throws NacosException {\n        if (meta == null || meta.getMetaVersion() == null) {\n            throw new NacosApiException(NacosException.SERVER_ERROR, ErrorCode.SERVER_ERROR,\n                \"Meta version missing\");\n        }\n        resourceManager.bumpMetaDescription(namespaceId, meta, description);\n    }\n    \n    private void validateVersion(String version) throws NacosApiException {\n        if (!PromptVersionUtils.isValidVersion(version)) {\n            throw new NacosApiException(NacosException.INVALID_PARAM,\n                ErrorCode.PARAMETER_VALIDATE_ERROR,\n                \"Version must be in format major.minor.patch, got: \" + version);\n        }\n    }\n    \n    /**\n     * Load all version rows for a prompt by paginating through all pages.\n     */\n    private List<AiResourceVersion> loadAllVersionRows(String namespaceId, String promptKey) {\n        List<AiResourceVersion> all = new ArrayList<>();","sourceCodeStart":909,"sourceCodeEnd":945,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/ai/src/main/java/com/alibaba/nacos/ai/service/prompt/PromptOperationServiceImpl.java#L909-L945","documentation":"Thrown by updateMetaDescriptionCas when the passed AiResource meta is null or its metaVersion field is null. This is a server-side programming error (HTTP 500, SERVER_ERROR code 30000) indicating the caller invoked a CAS update without a properly loaded meta row. It should never reach end users under normal operation.","triggerScenarios":"Internal code path calls updateMetaDescriptionCas with a meta object obtained from findMeta that returned null (prompt deleted between the initial load and the CAS call), or with a meta that has a null metaVersion due to a corrupted/partially-inserted row.","commonSituations":"Race condition: prompt deleted after loadMeta but before description update; database inconsistency leaving metaVersion null; internal refactoring passing an unloaded meta reference.","solutions":["Ensure the caller reloads the meta immediately before the CAS update and handles NOT_FOUND gracefully.","Add a null-check on meta before calling updateMetaDescriptionCas and throw a descriptive NOT_FOUND instead.","Investigate why the meta row was deleted or has a null metaVersion — this indicates a data integrity issue.","If seen in production, check for concurrent delete operations on the same prompt."],"exampleFix":"// before\nAiResource meta = resourceManager.findMeta(ns, key, RESOURCE_TYPE_PROMPT);\nupdateMetaDescriptionCas(ns, meta, newDesc); // meta may be null\n\n// after\nAiResource meta = resourceManager.requireMeta(ns, key, RESOURCE_TYPE_PROMPT);\nupdateMetaDescriptionCas(ns, meta, newDesc);","handlingStrategy":"try-catch","validationCode":"// Reload meta immediately before CAS update\nAiResource meta = resourceManager.requireMeta(ns, key, RESOURCE_TYPE_PROMPT);\nif (meta == null || meta.getMetaVersion() == null) {\n    // resource missing or corrupted — do not proceed\n    return;\n}","typeGuard":"boolean metaReadyForCas = meta != null && meta.getMetaVersion() != null;","tryCatchPattern":"try {\n    resourceManager.updateMetaDescriptionCas(ns, meta, newDesc);\n} catch (NacosApiException e) {\n    if (e.getErrCode() == NacosException.SERVER_ERROR\n        && e.getMessage().contains(\"Meta version missing\")) {\n        // reload and retry once, or report data integrity issue\n    }\n    throw e;\n}","preventionTips":["Always use requireMeta (which throws NOT_FOUND) instead of findMeta before CAS operations.","Never pass a stale or manually-constructed AiResource to a CAS update.","In code review, flag any path that calls updateMeta*Cas without a preceding fresh meta load."],"tags":["prompt","server-error","ai-registry","cas","data-integrity"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}