{"record":{"id":"1cef85d3271b9e8b","repo":"wavetermdev/waveterm","slug":"failed-to-get-job-w-1cef85","errorCode":null,"errorMessage":"failed to get job: %w","messagePattern":"failed to get job: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/wshutil/wshrouter_controlimpl.go","lineNumber":232,"sourceCode":"\treturn rtnData, nil\n}\n\nfunc (impl *WshRouterControlImpl) AuthenticateJobManagerVerifyCommand(ctx context.Context, data wshrpc.CommandAuthenticateJobManagerData) error {\n\tif !impl.Router.IsRootRouter() {\n\t\treturn fmt.Errorf(\"authenticatejobmanagerverify can only be called on root router\")\n\t}\n\n\tif data.JobId == \"\" {\n\t\treturn fmt.Errorf(\"no jobid in authenticatejobmanager message\")\n\t}\n\tif data.JobAuthToken == \"\" {\n\t\treturn fmt.Errorf(\"no jobauthtoken in authenticatejobmanager message\")\n\t}\n\n\tjob, err := wstore.DBMustGet[*waveobj.Job](ctx, data.JobId)\n\tif err != nil {\n\t\tlog.Printf(\"wshrouter authenticate-jobmanager-verify error jobid=%q: failed to get job: %v\", data.JobId, err)\n\t\treturn fmt.Errorf(\"failed to get job: %w\", err)\n\t}\n\n\tif job.JobAuthToken != data.JobAuthToken {\n\t\tlog.Printf(\"wshrouter authenticate-jobmanager-verify error jobid=%q: invalid jobauthtoken\", data.JobId)\n\t\treturn fmt.Errorf(\"invalid jobauthtoken\")\n\t}\n\n\tlog.Printf(\"wshrouter authenticate-jobmanager-verify success jobid=%q\", data.JobId)\n\treturn nil\n}\n\nfunc (impl *WshRouterControlImpl) AuthenticateJobManagerCommand(ctx context.Context, data wshrpc.CommandAuthenticateJobManagerData) error {\n\thandler := GetRpcResponseHandlerFromContext(ctx)\n\tif handler == nil {\n\t\treturn fmt.Errorf(\"no response handler in context\")\n\t}\n\tlinkId := handler.GetIngressLinkId()\n\tif linkId == baseds.NoLinkId {","sourceCodeStart":214,"sourceCodeEnd":250,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/wshutil/wshrouter_controlimpl.go#L214-L250","documentation":"The command looked up the Job record by JobId in wstore (DBMustGet) and the lookup failed — usually the job does not exist (or the DB read errored). The underlying wstore error is wrapped with %w, so inspecting the chain reveals whether it is a not-found error or a database failure.","triggerScenarios":"Calling AuthenticateJobManagerVerify with a JobId that has no corresponding *waveobj.Job in the wstore DB — deleted job, wrong id, different database/environment, or an actual DB read error.","commonSituations":"Job-manager restarted against a different WAVE datastore path; job record expired/purged before verification; stale job id cached on the client; database permission/IO problems.","solutions":["Check errors.Is/Unwrap on the error for a not-found result from wstore.DBMustGet.","Verify the JobId exists in the wstore DB used by the root router (same WAVE datastore).","Re-create the job and use the fresh job id for verification.","If it is a DB error (not not-found), check datastore file permissions/integrity and wstore logs."],"exampleFix":"// before\njob, err := wstore.DBMustGet[*waveobj.Job](ctx, data.JobId)\nif err != nil {\n    return fmt.Errorf(\"failed to get job: %w\", err)\n}\n// after\njob, err := wstore.DBGet[*waveobj.Job](ctx, data.JobId)\nif err != nil {\n    if wstore.IsNotFound(err) {\n        return fmt.Errorf(\"job %q not found: %w\", data.JobId, err)\n    }\n    return fmt.Errorf(\"failed to get job: %w\", err)\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"func isNotFoundErr(err error) bool {\n    return errors.Is(err, wstore.ErrNotFound) || strings.Contains(err.Error(), \"not found\")\n}","tryCatchPattern":"err := verifyJobManager(ctx, data)\nif err != nil {\n    if isNotFoundErr(errors.Unwrap(err)) {\n        // job record gone: recreate job and retry once with fresh id/token\n        return recreateJobAndVerify(ctx)\n    }\n    return fmt.Errorf(\"job lookup failed: %w\", err)\n}","preventionTips":["Ensure client and root point at the same WAVE datastore.","Handle job deletion/expiry by re-registering the job rather than retrying with the stale id.","Wrap DB errors so not-found is distinguishable via errors.Is."],"tags":["database","wstore","authentication"],"backgroundTag":"record-not-found","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}