Our GLSL shaders assume a fixed number of lights (the lights available in the Blender scene when the shader is generated). This causes issues when adding lamps to the scene with add object (T20275) or adding new lights via libload (T27030).
Some possible solutions:
Recompile shaders when the number of lights change. The problem with this is recompiling shaders can be slow, especially with lots of materials and no shader cache (I think only NVIDIA cards have a shader cache at the moment).
Change where shaders get light data from. We could pass an array of light structs (e.g., via uniform buffer objects) to shaders. This would allow us to change the number of lights in a scene (up to some maximum array size, unless we do texture objects, but that seems silly) without recompiling shaders. Unfortunately, this would introduce looping and branching into the generated code, which could slow down our shaders.
Move away from forward rendering. Techniques such as deferred/inferred rendering/lighting grab light data from a buffer that is filled at render time. This allows for a lot of dynamic lights, but we probably wouldn't want to drop our forward rendering, so this would only be a partial solution.