[generic] Add a test case for direct links with broken HEAD (#4032)