diff --git a/source/blender/gpu/opengl/gl_framebuffer.cc b/source/blender/gpu/opengl/gl_framebuffer.cc
index 13f03195437..7865d6facf8 100644
--- a/source/blender/gpu/opengl/gl_framebuffer.cc
+++ b/source/blender/gpu/opengl/gl_framebuffer.cc
@@ -429,6 +429,10 @@ void GLFrameBuffer::read(eGPUFrameBufferBits plane,
switch (plane) {
case GPU_DEPTH_BIT:
format = GL_DEPTH_COMPONENT;
+ BLI_assert_msg(
+ this->attachments_[GPU_FB_DEPTH_ATTACHMENT] ||
+ this->attachments_[GPU_FB_DEPTH_STENCIL_ATTACHMENT],
+ "GPUFramebuffer: Error: Trying to read depth without a depth buffer attached.");
break;
case GPU_COLOR_BIT:
format = channel_len_to_gl(channel_len);