{"record":{"id":"b5ff30c6e30cd9b6","repo":"temporalio/temporal","slug":"version-cannot-be-nil-on-start","errorCode":null,"errorMessage":"version cannot be nil on start","messagePattern":"version cannot be nil on start","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"service/worker/workerdeployment/version_workflow.go","lineNumber":253,"sourceCode":"\t\t\td.signalHandler.processingSignals++\n\t\t\tdefer func() { d.signalHandler.processingSignals-- }()\n\n\t\t\tvar vs wciiface.ValidationStatus\n\t\t\tc.Receive(ctx, &vs)\n\t\t\td.VersionState.ComputeStatus = wciValidationStatusToComputeStatus(&vs)\n\t\t\td.syncSummary(ctx) // propagate updated ComputeStatus to deployment workflow\n\t\t})\n\t}\n\n\t// Keep waiting for signals, when it's time to CaN the main goroutine will exit.\n\tfor {\n\t\td.signalHandler.signalSelector.Select(ctx)\n\t}\n}\n\nfunc (d *VersionWorkflowRunner) run(ctx workflow.Context) error {\n\tif d.GetVersionState().Version == nil {\n\t\treturn fmt.Errorf(\"version cannot be nil on start\")\n\t}\n\tif d.VersionState.GetCreateTime() == nil {\n\t\td.VersionState.CreateTime = timestamppb.New(workflow.Now(ctx))\n\t}\n\t// TODO: remove this after next release because now the status should always be set at start.\n\tif d.VersionState.Status == enumspb.WORKER_DEPLOYMENT_VERSION_STATUS_UNSPECIFIED {\n\t\td.VersionState.Status = enumspb.WORKER_DEPLOYMENT_VERSION_STATUS_INACTIVE\n\t}\n\n\t// if we were draining and just continued-as-new, do another drainage check after waiting for appropriate time\n\tif d.VersionState.GetDrainageInfo().GetStatus() == enumspb.VERSION_DRAINAGE_STATUS_DRAINING {\n\t\tworkflow.Go(ctx, d.refreshDrainageInfo)\n\t}\n\n\t// Set up Query Handlers here:\n\tif err := workflow.SetQueryHandler(ctx, QueryDescribeVersion, d.handleDescribeQuery); err != nil {\n\t\td.logger.Error(\"Failed while setting up query handler\")\n\t\treturn err","sourceCodeStart":235,"sourceCodeEnd":271,"githubUrl":"https://github.com/temporalio/temporal/blob/bde624efd13fbd3843654058db6d9c716166318b/service/worker/workerdeployment/version_workflow.go#L235-L271","documentation":"The worker deployment version workflow's run method requires VersionState.Version to be populated at start; if nil it returns this error, failing the workflow. It guards a core invariant — the workflow exists to manage a specific version, and its state should be initialized by VersionWorkflow before run executes.","triggerScenarios":"Starting VersionWorkflow with uninitialized state, e.g. after a malfunction in workflow construction, deserialization of an empty/legacy workflow state, or a bug where the version argument was never set.","commonSituations":"Temporal server/worker-deployment version upgrade where old workflows were created before state initialization was guaranteed; corrupted continue-as-new payloads; SDK-side misuse starting the workflow directly instead of via the deployment APIs.","solutions":["Ensure the version workflow is started through the WorkerDeployment client APIs which populate VersionState","If hit after an upgrade on an old workflow, let it fail and continue-as-new / recreate the version workflow","Report as a bug with the workflow history if the version was provably passed at start — it is an invariant violation"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"err := workflow.ExecuteWorkflow(...VersionWorkflow...).Get(ctx, &out)\nif err != nil && strings.Contains(err.Error(), \"version cannot be nil on start\") {\n    // restart the version workflow through the deployment client APIs\n}","preventionTips":["Always start version workflows via supported Worker Deployment APIs, never directly","After server upgrades, watch for legacy version workflows lacking initialized state","Report persistent occurrences with workflow history — it signals corrupted state"],"tags":["worker-deployment","workflow","invariant","go"],"backgroundTag":"missing-required-workflow-state","analyzedSha":"bde624efd13fbd3843654058db6d9c716166318b","analyzedAt":"2026-09-01T07:18:39.080Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}