=str #16221 loosen graph precondition checks when attaching Source/Sink

Cherry-copy-pasted from #16182.

Fixes #16221.