{"record":{"id":"37643f1568074cac","repo":"iflytek/astron-agent","slug":"version-id-is-null-skipping-audit-result-update","errorCode":null,"errorMessage":"Version ID is null, skipping audit result update","messagePattern":"Version ID is null, skipping audit result update","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/workflow/impl/WorkflowReleaseServiceImpl.java","lineNumber":296,"sourceCode":"            }\n\n            log.warn(\"SysData is empty for version: botId={}, versionName={}\", botId, versionName);\n            return null;\n\n        } catch (Exception e) {\n            log.error(\"Exception occurred while getting version system data: botId={}, versionName={}\",\n                    botId, versionName, e);\n            return null;\n        }\n    }\n\n    /**\n     * Update audit result\n     */\n    private boolean updateAuditResult(\n            Long versionId, String flowId, String auditResult, String executionUid, Long executionSpaceId) {\n        if (versionId == null) {\n            log.warn(\"Version ID is null, skipping audit result update\");\n            return false;\n        }\n\n        try {\n            log.info(\"Updating audit result: versionId={}, auditResult={}\", versionId, auditResult);\n\n            WorkflowVersion update = new WorkflowVersion();\n            update.setId(versionId);\n            update.setFlowId(flowId);\n            update.setPublishResult(auditResult);\n            var response = versionService.updateChannelResultForBoundBotPublish(\n                    update, executionUid, executionSpaceId);\n            if (response != null && response.code() == 0) {\n                log.info(\"Successfully updated audit result: versionId={}, auditResult={}\", versionId, auditResult);\n                return true;\n            }\n            log.error(\"Failed to update audit result: versionId={}, auditResult={}\", versionId, auditResult);\n            return false;","sourceCodeStart":278,"sourceCodeEnd":314,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/workflow/impl/WorkflowReleaseServiceImpl.java#L278-L314","documentation":"updateAuditResult is the callback that writes an audit/review outcome onto a workflow version row. If versionId is null it cannot target a row, so it logs a warning and returns false instead of throwing. The publish flow continues without the audit result being recorded.","triggerScenarios":"publishWorkflow completes and invokes the audit-result update while versionId is null — i.e. the version row was never created or its generated ID was not propagated back to the caller (insert failed silently, ID backfill disabled, or publish path skipped version creation).","commonSituations":"Publish where version creation was skipped or failed earlier; MyBatis-Plus insert without useGeneratedKeys so the entity id stays null; manual/mock invocation of the update with a null id; async audit callback racing ahead of version persistence.","solutions":["Fix the version creation path so publishWorkflow always has a non-null versionId before audit update (ensure useGeneratedKeys/id backfill)","Guard publishWorkflow: abort or queue the audit update when versionId is null rather than calling with null","Return false is current behavior — make callers check the boolean and alert when audit result was not persisted","Log botId/publish context alongside the warning for traceability"],"exampleFix":"// before\nif (versionId == null) {\n    log.warn(\"Version ID is null, skipping audit result update\");\n    return false;\n}\n// after\nif (versionId == null) {\n    log.error(\"Version ID is null for flowId={}, audit result not persisted\", flowId);\n    throw new IllegalStateException(\"Cannot update audit result: versionId is null\");\n}","handlingStrategy":"type-guard","validationCode":"// before updating audit result\nif (version == null || version.getId() == null) {\n    throw new IllegalStateException(\"Publish failed: no persisted version id for flowId \" + flowId);\n}","typeGuard":"boolean canUpdateAudit(WorkflowVersion v) { return v != null && v.getId() != null; }","tryCatchPattern":"boolean updated = service.updateAuditResult(versionId, flowId, result, uid, spaceId);\nif (!updated) {\n    log.error(\"Audit result not persisted for flowId={} (versionId={})\", flowId, versionId);\n    auditRetryQueue.add(new AuditUpdate(versionId, flowId, result));\n}","preventionTips":["Configure MyBatis-Plus id auto-generation (KeyGenerator/useGeneratedKeys) so inserted entities carry their id","Always create-and-persist the version row before scheduling audit callbacks","Check the boolean return of updateAuditResult and alert/retry on false","Include botId and flowId in the warn log for faster triage"],"tags":["java","audit","null-check","publish"],"backgroundTag":"null-argument","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-19T12:17:13.211Z"}