Weird API behaviour when listing all commits on a rebased repository

This happens on GitLab Community Edition 14.2.1. I have a project and thus repository which is quite simple (just main branch, sequential commits produced by scripts). However due to some mishap one of the scripts produced a large amount (around 40k) of superfluous commits that interleave with valid commits.After taking the script off-line we had to do interactive rebase to get rid of all the redundant commits. Apart from git push --force taking a lot of time this went very well. By that I mean repository commits view shows what it is supposed to show (at least it is consistent with what git log shows).The problem is with API and to be more precise with /projects/:id/repository/commits?all=true endpoint. As you might have guessed, among returned commits, we get the removed commits. If we use web_url from the removed commit, we can get to commit view and it renders correctly. Yet it is still unreachable from repository commits view, because it shows only what git log shows.

It would be great if somebody can point out if this is know behaviour or a potential bug that needs to be reported.