backport #28213 This PR will fix some missed checks for private repositories' data on web routes and API routes. (cherry picked from commit dfd511faf3)
dfd511faf3