{"record":{"id":"631e657918f7d852","repo":"gravitational/teleport","slug":"decoder-has-no-pixel-format","errorCode":null,"errorMessage":"decoder has no pixel format","messagePattern":"decoder has no pixel format","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/srv/desktop/rdp/decoder/decoder.go","lineNumber":177,"sourceCode":"\n\treturn rgba\n}\n\n// ResizeCrop returns the source crop region (cropX, cropY, cropW, cropH) scaled to exactly outWidth x outHeight using\n// high-quality CatmullRom convolution. The crop must lie within the current frame bounds. When withCursor is true and\n// the decoder's tracked cursor is visible, it is composited onto the source frame before the crop is taken, so the\n// cursor scales with the screen.\nfunc (d *Decoder) ResizeCrop(cropX, cropY, cropW, cropH, outWidth, outHeight uint16, withCursor bool) (*image.RGBA, error) {\n\tif d == nil || d.ptr == nil {\n\t\treturn nil, errors.New(\"decoder not initialized\")\n\t}\n\tif outWidth == 0 || outHeight == 0 || cropW == 0 || cropH == 0 {\n\t\treturn nil, errors.New(\"invalid resize dimensions\")\n\t}\n\n\tbpp := int(C.rdp_decoder_bytes_per_pixel(d.ptr))\n\tif bpp == 0 {\n\t\treturn nil, errors.New(\"decoder has no pixel format\")\n\t}\n\n\tw, h := int(outWidth), int(outHeight)\n\tbuf := make([]byte, w*h*bpp)\n\n\tvar withCursorC C.uint8_t\n\tif withCursor {\n\t\twithCursorC = 1\n\t}\n\n\tok := C.rdp_decoder_resize_crop(\n\t\td.ptr,\n\t\tC.uint16_t(cropX),\n\t\tC.uint16_t(cropY),\n\t\tC.uint16_t(cropW),\n\t\tC.uint16_t(cropH),\n\t\tC.uint16_t(outWidth),\n\t\tC.uint16_t(outHeight),","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/gravitational/teleport/blob/1283425b60ec5f60d509ba4c791183d452923ff7/lib/srv/desktop/rdp/decoder/decoder.go#L159-L195","documentation":"ResizeCrop queries the C decoder for its bytes-per-pixel value; bpp==0 means the underlying rdp_decoder has no recognized pixel format (the decoder was never initialized with a source format, so output buffer sizing is impossible). The library throws this instead of allocating a bogus zero-byte buffer.","triggerScenarios":"Calling ResizeCrop on a decoder whose native pixel format was never set/initialized (C.rdp_decoder_bytes_per_pixel returns 0), e.g. before the first frame is decoded or after a failed decoder init.","commonSituations":"Calling ResizeCrop on a fresh/failed decoder before any decoded frame arrives; RDP backend built without graphics support; decoder initialized with an unsupported bpp format.","solutions":["Ensure the decoder successfully decoded at least one frame before calling ResizeCrop","Verify the RDP decoder was initialized with a supported pixel format (check New/Init options)","Check that the CGO backend (rdp_decoder) is the real build, not a stub","Log bpp and decoder state before calling ResizeCrop to detect uninitialized state"],"exampleFix":"// before\nimg, err := dec.ResizeCrop(...)\n// after\nif dec.DecodedFrames() == 0 {\n    return nil, errors.New(\"cannot resize crop before a frame is decoded\")\n}\nimg, err := dec.ResizeCrop(...)","handlingStrategy":"validation","validationCode":"bpp := int(C.rdp_decoder_bytes_per_pixel(d.ptr))\nif bpp == 0 {\n    return nil, errors.New(\"cannot resize: decoder has no pixel format; decode a frame first\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only call ResizeCrop after at least one successful decode","Verify decoder init succeeded before using it","Surface decoder state in health checks"],"tags":["rdp","desktop","cgo","video-decoding"],"backgroundTag":"uninitialized-decoder-state","analyzedSha":"1283425b60ec5f60d509ba4c791183d452923ff7","analyzedAt":"2026-09-02T04:06:41.601Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}