Orphan/dangling references to page layouts that can't be seen in the UI

I’m unsure if this is a known issue, but when I delete unneeded pages or modules, it leaves behind orphan/dangling references to page layouts that can’t be seen in the UI. This becomes an issue when we update/ provision a new environment via Terraform, as we need to manually delete errors one by one during deployments. We have a workaround but it is a bit messy.

I’m looking for suggestions on how we identify or prevent orphan/dangling references in the first place?

I believe I have a related issue, I can’t export namespaces because of some orphaned modules/fields/pages that were deleted in the meantime.
It’s mentioned here:

I also created Github issue:

It seems it’s set to be fixed in release 2023.9.1, whenever it might be:

2 Likes