Detect depends-on cycles and throw proper exception

Issue: SPR-7966