Retrieves by related ID updated to test for invalid relationships.

[ci skip]