Querying size of stencil buffer in Core 3.x

In GL 3.x, glGetIntegerv with GL_STENCIL_BITS is deprecated.
For querying frame buffer parameters there is glGetFramebufferAttachmentParameteriv.
According to the spec this should work for the default framebuffer:


int stencilBits;
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_STENCIL, GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE, &stencilBits);

However, a GL_INVALID_ENUM is returned.
What’s wrong with that?