Skip to content

Conversation

@mrnugget
Copy link
Contributor

@mrnugget mrnugget commented Apr 3, 2020

This fixes https://github.com/sourcegraph/sourcegraph/issues/9149

When a repository is being cloned while we execute the scopeQuery of
an action, the GraphQL query returns something like this:

{
  "errors": [
    {
      "message": "repository does not exist: github.com/sourcegraphtest/alwayscloningtest",
      "path": [ "search", "results", "results", 2, "defaultBranch" ]
    }
  ],
  "data": {
    "search": {
      "results": {
        "results": [
          {
            "__typename": "Repository",
            "id": "UmVwb3NpdG9yeTox",
            "name": "github.com/sourcegraph/automation-testing",
            "defaultBranch": { "name": "refs/heads/master", "target": { "oid": "3a0d12026c1349c4aefb712145433cc26c330a06" }
            }
          },
          {
            "__typename": "Repository",
            "id": "UmVwb3NpdG9yeTozOTU=",
            "name": "github.com/sourcegraphtest/AlwaysCloningTest",
            "defaultBranch": null
          }
        ]
      }
    }
  }
}

There is an error for AlwaysCloningTest but AlwaysCloningTest is
also being returned in the data, except that its defaultBranch is
null.

So instead of returning an error when one of the repositories is being
cloned and doesn't have a default branch, we simply check for the
existence of the defaultBranch attribute and if it's not there, we
skip the repository.

This fixes https://github.com/sourcegraph/sourcegraph/issues/9149

When a repository is being cloned while we execute the `scopeQuery` of
an action, the GraphQL query returns something like this:

    {
      "errors": [
        {
          "message": "repository does not exist: github.com/sourcegraphtest/alwayscloningtest",
          "path": [ "search", "results", "results", 2, "defaultBranch" ]
        }
      ],
      "data": {
        "search": {
          "results": {
            "results": [
              {
                "__typename": "Repository",
                "id": "UmVwb3NpdG9yeTox",
                "name": "github.com/sourcegraph/automation-testing",
                "defaultBranch": { "name": "refs/heads/master", "target": { "oid": "3a0d12026c1349c4aefb712145433cc26c330a06" }
                }
              },
              {
                "__typename": "Repository",
                "id": "UmVwb3NpdG9yeTozOTU=",
                "name": "github.com/sourcegraphtest/AlwaysCloningTest",
                "defaultBranch": null
              }
            ]
          }
        }
      }
    }

There is an error for `AlwaysCloningTest` but `AlwaysCloningTest` is
also being returned in the data, except that its `defaultBranch` is
`null`.

So instead of returning an error when one of the repositories is being
cloned and doesn't have a default branch, we simply check for the
existence of the `defaultBranch` attribute and if it's not there, we
skip the repository.
@mrnugget mrnugget requested review from eseliger and ryanslade April 3, 2020 14:16
@mrnugget mrnugget merged commit 007f16c into master Apr 3, 2020
@eseliger
Copy link
Member

eseliger commented Apr 3, 2020

nice 🎊 Reminder to myself: port this to actions-runner

@eseliger eseliger deleted the skip-repos-being-cloned branch April 3, 2020 15:15
@mrnugget mrnugget added the action-exec Everything related to the action exec functionality label Apr 17, 2020
scjohns pushed a commit that referenced this pull request Apr 24, 2023
…ror (#173)

This fixes https://github.com/sourcegraph/sourcegraph/issues/9149

When a repository is being cloned while we execute the `scopeQuery` of
an action, the GraphQL query returns something like this:

    {
      "errors": [
        {
          "message": "repository does not exist: github.com/sourcegraphtest/alwayscloningtest",
          "path": [ "search", "results", "results", 2, "defaultBranch" ]
        }
      ],
      "data": {
        "search": {
          "results": {
            "results": [
              {
                "__typename": "Repository",
                "id": "UmVwb3NpdG9yeTox",
                "name": "github.com/sourcegraph/automation-testing",
                "defaultBranch": { "name": "refs/heads/master", "target": { "oid": "3a0d12026c1349c4aefb712145433cc26c330a06" }
                }
              },
              {
                "__typename": "Repository",
                "id": "UmVwb3NpdG9yeTozOTU=",
                "name": "github.com/sourcegraphtest/AlwaysCloningTest",
                "defaultBranch": null
              }
            ]
          }
        }
      }
    }

There is an error for `AlwaysCloningTest` but `AlwaysCloningTest` is
also being returned in the data, except that its `defaultBranch` is
`null`.

So instead of returning an error when one of the repositories is being
cloned and doesn't have a default branch, we simply check for the
existence of the `defaultBranch` attribute and if it's not there, we
skip the repository.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action-exec Everything related to the action exec functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Searching repositories with src action exec fails if they're being cloned

4 participants