I think there was a very similar topic a while ago. While the driver cannot just drop the uniform from the uniform block it is under no obligation to supply you with a valid index while the uniform is not used in that particular shader (even though space is reserved for the uniform).
ok! Doesn't sound unreasonable.
But Is there still a mechanic/technique, that allows me to query layout information even though I don't use any variable at all ?