This is a repro that triggers an assert (only) in REL_12_STABLE. In particular the issue seems to have begun after this commit - 08d2d58a2a1c8ef8d39e8132d39ee14a1d029500. The foreign table is empty so am unsure if Assert()'s expectations are valid.
Since all versions v13+ seem to work okay, it is possible that a future bug-fix was not backpatched far enough to v12.
Yes, I think it is 5e7fa189e, which should be back-patched to v12.