{"record":{"id":"16b34ebe2532d8da","repo":"hashicorp/nomad","slug":"failed-variable-lookup-s","errorCode":null,"errorMessage":"failed variable lookup: %s","messagePattern":"failed variable lookup: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/state/state_store_variables.go","lineNumber":164,"sourceCode":"\n\tresp := s.varSetCASTxn(tx, idx, sv)\n\tif resp.IsError() || resp.IsConflict() {\n\t\treturn resp\n\t}\n\n\tif err := tx.Commit(); err != nil {\n\t\treturn sv.ErrorResponse(idx, err)\n\t}\n\treturn resp\n}\n\n// varSetCASTxn is the inner method used to do a CAS inside an existing\n// transaction.\nfunc (s *StateStore) varSetCASTxn(tx WriteTxn, idx uint64, req *structs.VarApplyStateRequest) *structs.VarApplyStateResponse {\n\tsv := req.Var\n\traw, err := tx.First(TableVariables, indexID, sv.Namespace, sv.Path)\n\tif err != nil {\n\t\treturn req.ErrorResponse(idx, fmt.Errorf(\"failed variable lookup: %s\", err))\n\t}\n\tsvEx, ok := raw.(*structs.VariableEncrypted)\n\n\t// ModifyIndex of 0 means that we are doing a set-if-not-exists.\n\tif sv.ModifyIndex == 0 && raw != nil {\n\t\treturn req.ConflictResponse(idx, svEx)\n\t}\n\n\t// If the ModifyIndex is set but the variable doesn't exist, return a\n\t// plausible zero value as the conflict\n\tif sv.ModifyIndex != 0 && raw == nil {\n\t\tzeroVal := &structs.VariableEncrypted{\n\t\t\tVariableMetadata: structs.VariableMetadata{\n\t\t\t\tNamespace: sv.Namespace,\n\t\t\t\tPath:      sv.Path,\n\t\t\t},\n\t\t}\n\t\treturn req.ConflictResponse(idx, zeroVal)","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/state/state_store_variables.go#L146-L182","documentation":"During a variable CAS set, reading the existing variable by namespace/path from memdb failed; the wrapped First error prevents compare-and-swap evaluation and is returned as an error response.","triggerScenarios":"Thrown at nomad/state/state_store_variables.go:164 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry the variable write","Inspect server logs for state store read errors"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}