{"record":{"id":"364ae2b98517cdbd","repo":"m1k1o/neko","slug":"image-data-not-found","errorCode":null,"errorMessage":"image data not found","messagePattern":"image data not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"server/internal/capture/screencast.go","lineNumber":144,"sourceCode":"\tmanager.mu.Lock()\n\tdefer manager.mu.Unlock()\n\n\treturn manager.started\n}\n\nfunc (manager *ScreencastManagerCtx) Image() ([]byte, error) {\n\tatomic.StoreInt32(&manager.expired, 0)\n\n\terr := manager.start()\n\tif err != nil && !errors.Is(err, types.ErrCapturePipelineAlreadyExists) {\n\t\treturn nil, err\n\t}\n\n\tmanager.imageMu.Lock()\n\tdefer manager.imageMu.Unlock()\n\n\tif manager.image.Data == nil {\n\t\treturn nil, errors.New(\"image data not found\")\n\t}\n\n\treturn manager.image.Data, nil\n}\n\nfunc (manager *ScreencastManagerCtx) start() error {\n\tmanager.mu.Lock()\n\tdefer manager.mu.Unlock()\n\n\tif !manager.enabled {\n\t\treturn errors.New(\"screencast not enabled\")\n\t}\n\n\terr := manager.createPipeline()\n\tif err != nil {\n\t\treturn err\n\t}\n","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/m1k1o/neko/blob/b0f01cedea68893e85a3fd852c0521238c285695/server/internal/capture/screencast.go#L126-L162","documentation":"GetImage on the screencast manager returns this error when the cached image buffer (manager.image.Data) is nil, meaning no frame has ever been captured and stored. The library throws it because there is no screenshot data to hand back to the caller yet. It is a signal that the screencast pipeline has not produced its first sample (or was never started) before GetImage was called.","triggerScenarios":"Calling ScreencastManagerCtx.GetImage() before the pipeline has stored any frame — e.g. right after construction with no prior start/Image invocation that populated manager.image, or after creation where the first-sample select in createPipeline stored nothing.","commonSituations":"Developers hit this when taking an immediate screenshot on session open without waiting for the screencast to start; after toggling screencast off/on; in headless environments where GStreamer never emits a first sample; or when wiring a new client that fetches an image before any streaming client triggered pipeline creation.","solutions":["Ensure the screencast is started (or an existing streaming session exists) before calling GetImage, so createPipeline populates the first image","Retry GetImage with a short backoff until the first frame arrives instead of calling it once immediately","Enable the screencast via its config/manager so start() runs and sets an initial image","Verify the underlying capture pipeline (GStreamer) actually emits samples — check logs for 'started receiving images'"],"exampleFix":"// before\nimg, err := screencastManager.GetImage() // may fail: image data not found\n// after\nif err := screencastManager.StartStreamingIfStopped(); err != nil { return err }\nfor i := 0; i < 10; i++ {\n    img, err := screencastManager.GetImage()\n    if err == nil { return img }\n    time.Sleep(100 * time.Millisecond)\n}","handlingStrategy":"retry","validationCode":"// No public accessor for image state; validate indirectly by ensuring the screencast was started first.\nif screencastManager == nil {\n    return errors.New(\"screencast manager not initialized\")\n}\n// Optionally attempt start (idempotent) before fetching:\nif err := ensureScreencastStarted(); err != nil { return err }","typeGuard":"func hasImageData(m *capture.ScreencastManagerCtx) bool {\n    // Only reachable via GetImage error; treat error as the guard.\n    _, err := m.GetImage()\n    return err == nil\n}","tryCatchPattern":"img, err := manager.GetImage()\nif err != nil {\n    if err.Error() == \"image data not found\" {\n        // first frame not ready yet: retry with backoff\n        time.Sleep(200 * time.Millisecond)\n        img, err = manager.GetImage()\n    }\n    if err != nil { return err }\n}","preventionTips":["Always start the screencast (or have an active stream) before calling GetImage","Retry the first GetImage with backoff rather than failing immediately","Log pipeline start events and correlate with image fetch failures","Treat the first frame as asynchronous — poll until available"],"tags":["go","screencast","capture","nil-data"],"backgroundTag":"no-frame-available","analyzedSha":"b0f01cedea68893e85a3fd852c0521238c285695","analyzedAt":"2026-09-01T10:35:56.638Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}