{"record":{"id":"7203562f4e2970b2","repo":"wavetermdev/waveterm","slug":"error-getting-object-w","errorCode":null,"errorMessage":"error getting object: %w","messagePattern":"error getting object: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/service/objectservice/objectservice.go","lineNumber":48,"sourceCode":"}\n\nfunc (svc *ObjectService) GetObject_Meta() tsgenmeta.MethodMeta {\n\treturn tsgenmeta.MethodMeta{\n\t\tDesc:     \"get wave object by oref\",\n\t\tArgNames: []string{\"oref\"},\n\t}\n}\n\nfunc (svc *ObjectService) GetObject(orefStr string) (waveobj.WaveObj, error) {\n\toref, err := parseORef(orefStr)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tctx, cancelFn := context.WithTimeout(context.Background(), DefaultTimeout)\n\tdefer cancelFn()\n\tobj, err := wstore.DBGetORef(ctx, *oref)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error getting object: %w\", err)\n\t}\n\treturn obj, nil\n}\n\nfunc (svc *ObjectService) GetObjects_Meta() tsgenmeta.MethodMeta {\n\treturn tsgenmeta.MethodMeta{\n\t\tArgNames:   []string{\"orefs\"},\n\t\tReturnDesc: \"objects\",\n\t}\n}\n\nfunc (svc *ObjectService) GetObjects(orefStrArr []string) ([]waveobj.WaveObj, error) {\n\tctx, cancelFn := context.WithTimeout(context.Background(), DefaultTimeout)\n\tdefer cancelFn()\n\n\tvar orefArr []waveobj.ORef\n\tfor _, orefStr := range orefStrArr {\n\t\torefObj, err := parseORef(orefStr)","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/service/objectservice/objectservice.go#L30-L66","documentation":"GetObject wraps failures from wstore.DBGetORef with 'error getting object: %w'. The oref parsed fine but no object of the given type/oid exists in wstore (or the DB read failed). Most commonly the wrapped error is a 'key not found' from the store.","triggerScenarios":"Calling ObjectService.GetObject with an oref whose OID was deleted (closed block/tab), whose type prefix is wrong for the stored object, or on DB read failure.","commonSituations":"Referencing a block after the tab containing it was closed; stale orefs cached in the frontend across restarts; mixing up block vs. tab OTypes.","solutions":["Check the wrapped error: 'key not found' means the object is gone — refresh from the live object list","Verify the OType prefix matches the actual object type stored","Re-resolve the OID from the current tab/window state instead of a cached value"],"exampleFix":"// before\nobj, err := svc.GetObject(ctx, cachedOref)\n// after\nif _, err := svc.GetObject(ctx, cachedOref); err != nil && strings.Contains(err.Error(), \"key not found\") {\n    cachedOref = resolveCurrentOref(ctx) // refresh from live state\n}","handlingStrategy":"try-catch","validationCode":"if !strings.Contains(orefStr, \":\") { return fmt.Errorf(\"malformed oref\") }","typeGuard":null,"tryCatchPattern":"obj, err := svc.GetObject(ctx, orefStr)\nif err != nil {\n    if strings.Contains(err.Error(), \"key not found\") { /* stale ref; refresh */ }\n    return err\n}","preventionTips":["Re-resolve orefs from live state after tabs/blocks close","Verify the OType prefix matches the object you expect","Avoid caching orefs across app restarts"],"tags":["go","database","wstore","oref"],"backgroundTag":"record-not-found","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}