Avoid key error in connected_ids()

Continue through the loop if we could't access the grains instead of
crashing and burning.

Closes #15143
Merge pull request #16798 from cachedout/issue_15143

Avoid key error in connected_ids()