The legacy-path renameCollection must fail if either the source or the destination collections are sharded.
It does so by checking if the filtering metadata has the collection as sharded or not.
There is a situation where after a shardCollection operations has completed writing the config.chunks and config.collections documents, but then steps down before refreshing the filtering metadata, where the new primary may be left with filtering metadata as unsharded. Under that scenario, a legacy-path rename may succeed in renaming a sharded collection.