GraphQL cannot handle some queries for repositories when they are empty
### Summary
When there is no repository, some GraphQL queries can fail with a 500 and are not handled gracefully.
An example query:
```graphql
query {
group(fullPath: "top-level-group/subgroup") {
projects(includeSubgroups: true, includeArchived: false) {
pageInfo {
endCursor
hasNextPage
}
count
nodes {
name
fullPath
webUrl
repository {
rootRef
lastCommitOnDefaultBranch: lastCommit{
committedDate
}
lastCommitOnMain: lastCommit(ref: "main") {
committedDate
}
lastCommitOnMaster: lastCommit(ref: "master") {
committedDate
}
ciFileOnDefaultBranch: blobs (paths: [".gitlab-ci.yml"]) {
nodes {
webPath
rawTextBlob
}
}
ciFileOnMainBranch: blobs (ref: "main", paths:[".gitlab-ci.yml"]){
nodes{
webPath
rawTextBlob
}
}
treeOnMainBranch: tree(ref: "main") {
trees {
nodes {
name
type
}
}
}
treeOnDefaultBranch: tree{
trees {
nodes {
name
type
}
}
}
}
}
}
}
}
```
In this case, when a project is found that has no repository, we end up with an internal server error:
```json
{
"errors": [
{
"name": "ServerError",
"response": {},
"statusCode": 500,
"result": {
"errors": [
{
"message": "Internal server error"
}
]
},
"message": "Response not successful: Received status code 500",
"stack": "ServerError: Response not successful: Received status code 500\n at i (https://gitlab.com/assets/webpack/main.be23ca8b.chunk.js:69:157462)\n at https://gitlab.com/assets/webpack/main.be23ca8b.chunk.js:63:90378"
}
]
}
```
In this case, Gitaly is reporting `5:repository not found.` because it does not exist on some projects:

This is different from a project that has an empty repository. We should be able to handle scenarios where a repo does not exist, or at the very least filter them out in some way.
<details><summary>Backtrace</summary>
```
"exception.message": "5:repository not found.",
"db_main_txn_count": 0,
"db_ci_duration_s": 0,
"exception.cause_class": "GRPC::NotFound",
"db_sec_txn_max_duration_s": 0,
"cpu_s": 3.007287,
"remote_ip": "23.114.197.183",
"redis_sessions_calls": 3,
"db_sec_replica_wal_count": 0,
"request_urgency": "low",
"exception.backtrace": [
"lib/gitlab/git/wraps_gitaly_errors.rb:44:in `handle_default_error'",
"lib/gitlab/git/wraps_gitaly_errors.rb:23:in `handle_error'",
"lib/gitlab/git/wraps_gitaly_errors.rb:14:in `rescue in wrapped_gitaly_errors'",
"lib/gitlab/git/wraps_gitaly_errors.rb:6:in `wrapped_gitaly_errors'",
"lib/gitlab/git/repository.rb:388:in `log'",
"lib/gitlab/git/commit.rb:60:in `where'",
"lib/gitlab/git/commit.rb:109:in `last_for_path'",
"app/graphql/resolvers/last_commit_resolver.rb:43:in `resolve'",
"lib/gitlab/graphql/present/field_extension.rb:18:in `resolve'",
"lib/gitlab/graphql/tracers/instrumentation_tracer.rb:23:in `execute_multiplex'",
"app/graphql/gitlab_schema.rb:44:in `multiplex'",
"app/controllers/graphql_controller.rb:253:in `execute_query'",
"app/controllers/graphql_controller.rb:65:in `execute'",
"app/controllers/application_controller.rb:494:in `set_current_admin'",
"lib/gitlab/session.rb:11:in `with_session'",
"app/controllers/application_controller.rb:485:in `set_session_storage'",
"lib/gitlab/i18n.rb:114:in `with_locale'",
"lib/gitlab/i18n.rb:120:in `with_user_locale'",
"app/controllers/application_controller.rb:476:in `set_locale'",
"app/controllers/application_controller.rb:465:in `set_current_context'",
"lib/gitlab/ip_address_state.rb:11:in `with'",
"app/controllers/application_controller.rb:471:in `set_current_ip_address'",
"lib/gitlab/middleware/action_controller_static_context.rb:23:in `call'",
"config/initializers/action_dispatch_journey_router.rb:53:in `block in find_routes'",
"config/initializers/action_dispatch_journey_router.rb:25:in `map!'",
"config/initializers/action_dispatch_journey_router.rb:25:in `find_routes'",
"ee/lib/omni_auth/strategies/group_saml.rb:41:in `other_phase'",
"lib/gitlab/metrics/elasticsearch_rack_middleware.rb:16:in `call'",
"lib/gitlab/middleware/sidekiq_shard_awareness_validation.rb:20:in `block in call'",
"lib/gitlab/sidekiq_sharding/validator.rb:42:in `enabled'",
"lib/gitlab/middleware/sidekiq_shard_awareness_validation.rb:20:in `call'",
"lib/gitlab/middleware/memory_report.rb:13:in `call'",
"lib/gitlab/middleware/speedscope.rb:13:in `call'",
"lib/gitlab/database/load_balancing/rack_middleware.rb:23:in `call'",
"lib/gitlab/middleware/rails_queue_duration.rb:33:in `call'",
"lib/gitlab/etag_caching/middleware.rb:21:in `call'",
"lib/gitlab/metrics/rack_middleware.rb:16:in `block in call'",
"lib/gitlab/metrics/web_transaction.rb:46:in `run'",
"lib/gitlab/metrics/rack_middleware.rb:16:in `call'",
"lib/gitlab/middleware/go.rb:21:in `call'",
"lib/gitlab/middleware/query_analyzer.rb:11:in `block in call'",
"lib/gitlab/database/query_analyzer.rb:83:in `within'",
"lib/gitlab/middleware/query_analyzer.rb:11:in `call'",
"lib/ci/job_token/middleware.rb:11:in `call'",
"lib/gitlab/middleware/multipart.rb:173:in `call'",
"lib/gitlab/middleware/read_only/controller.rb:50:in `call'",
"lib/gitlab/middleware/read_only.rb:18:in `call'",
"lib/gitlab/middleware/unauthenticated_session_expiry.rb:18:in `call'",
"lib/gitlab/middleware/secure_headers.rb:11:in `call'",
"lib/gitlab/middleware/same_site_cookies.rb:27:in `call'",
"lib/gitlab/middleware/path_traversal_check.rb:40:in `call'",
"lib/gitlab/middleware/handle_malformed_strings.rb:21:in `call'",
"lib/gitlab/middleware/basic_health_check.rb:25:in `call'",
"lib/gitlab/middleware/handle_ip_spoof_attack_error.rb:25:in `call'",
"lib/gitlab/middleware/request_context.rb:15:in `call'",
"lib/gitlab/middleware/webhook_recursion_detection.rb:15:in `call'",
"config/initializers/fix_local_cache_middleware.rb:11:in `call'",
"lib/gitlab/middleware/compressed_json.rb:44:in `call'",
"lib/gitlab/middleware/rack_multipart_tempfile_factory.rb:19:in `call'",
"lib/gitlab/metrics/requests_rack_middleware.rb:83:in `call'",
"lib/gitlab/middleware/sidekiq_web_static.rb:20:in `call'",
"lib/gitlab/middleware/release_env.rb:12:in `call'"
],
<TRUNCATED>
"json.graphql.used_fields": [
"PageInfo.endCursor",
"PageInfo.hasNextPage",
"ProjectConnection.pageInfo",
"ProjectConnection.count",
"Project.name",
"Project.fullPath",
"Project.webUrl",
"Repository.rootRef",
"Commit.committedDate",
"Repository.lastCommit",
"RepositoryBlob.webPath",
"RepositoryBlob.rawTextBlob",
"RepositoryBlobConnection.nodes",
"Repository.blobs",
"TreeEntry.name",
"TreeEntry.type",
"TreeEntryConnection.nodes",
"Tree.trees",
"Repository.tree",
"Project.repository",
"ProjectConnection.nodes",
"Group.projects",
"Query.group"
],
```
</details>
### Steps to reproduce
1. Use the above query to query any group that contains a project that does not have a repository
### Example Project
It can be replicated on my own test group:
- https://gitlab.com/cleveland_ultimate_group
### What is the current *bug* behavior?
A 500 error is returned when running a GraphQL query that attempts to get repository info on a project with no repository.
### What is the expected *correct* behavior?
We skip or can filter out projects with no repositories, or more gracefully handle 500 errors in these query scenarios.
### Relevant logs and/or screenshots
<!-- Paste any relevant logs - please use code blocks (```) to format console output, logs, and code
as it's tough to read otherwise. -->
### Output of checks
This bug happens on GitLab.com
#### Results of GitLab environment info
<!-- Input any relevant GitLab environment information if needed. -->
<details>
<summary>Expand for output related to GitLab environment info</summary>
<pre>
(For installations with omnibus-gitlab package run and paste the output of:
`sudo gitlab-rake gitlab:env:info`)
(For installations from source run and paste the output of:
`sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)
</pre>
</details>
#### Results of GitLab application Check
<!-- Input any relevant GitLab application check information if needed. -->
<details>
<summary>Expand for output related to the GitLab application check</summary>
<pre>
(For installations with omnibus-gitlab package run and paste the output of:
`sudo gitlab-rake gitlab:check SANITIZE=true`)
(For installations from source run and paste the output of:
`sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true`)
(we will only investigate if the tests are passing)
</pre>
</details>
### Possible fixes
<!-- If you can, link to the line of code that might be responsible for the problem. -->
### Patch release information for backports
If the bug fix needs to be backported in a [patch release](https://handbook.gitlab.com/handbook/engineering/releases/patch-releases) to a version
under [the maintenance policy](https://docs.gitlab.com/policy/maintenance/), please follow the steps on the
[patch release runbook for GitLab engineers](https://gitlab.com/gitlab-org/release/docs/-/blob/master/general/patch/engineers.md).
Refer to the [internal "Release Information" dashboard](https://dashboards.gitlab.net/d/delivery-release_info/delivery3a-release-information?orgId=1)
for information about the next patch release, including the targeted versions, expected release date, and current status.
#### High-severity bug remediation
To remediate high-severity issues requiring an [internal release](https://handbook.gitlab.com/handbook/engineering/releases/internal-releases/) for single-tenant SaaS instances,
refer to the [internal release process for engineers](https://gitlab.com/gitlab-org/release/docs/-/blob/master/general/internal-releases/engineers.md?ref_type=heads).
issue