Skip to content

“get a reference” API does not accept SHAs as documented (/repos/{owner}/{repo}/git/ref/{ref}) #31914

Description

@flying-sheep

Code of Conduct

What article on docs.github.com is affected?

The docs for this endpoint say /repos/{owner}/{repo}/git/ref/{ref}:

ref string Required

The commit reference. Can be a commit SHA, branch name (heads/BRANCH_NAME), or tag name (tags/TAG_NAME). For more information, see "Git References" in the Git documentation.

(emphasis mine)

Yet the ref API responds with 404 when used with a (valid) commit SHA:

$ gh api repos/scverse/anndata/git/ref/a4786471ee4d4e894fec150e426c3551db0f31e0
gh: Not Found (HTTP 404)
{
  "message": "Not Found",
  "documentation_url": "https://docs.github.com/rest/git/refs#get-a-reference"
}

whereas the commits API works:

$ gh api repos/scverse/anndata/commits/a4786471ee4d4e894fec150e426c3551db0f31e0
{
  "sha": "a4786471ee4d4e894fec150e426c3551db0f31e0",
  "node_id": "C_kwDOBfZ26doAKGE0Nzg2NDcxZWU0ZDRlODk0ZmVjMTUwZTQyNmMzNTUxZGIwZjMxZTA",
  "commit": {...},
  ...
}

using the ref API with e.g. branch also works as documented:

$ gh api repos/scverse/anndata/git/ref/heads/main
{
  "ref": "refs/heads/main",
  "node_id": "MDM6UmVmMTAwMDM4Mzc3OnJlZnMvaGVhZHMvbWFpbg==",
  "url": "https://api.github.com/repos/scverse/anndata/git/refs/heads/main",
  "object": {
    "sha": "a4786471ee4d4e894fec150e426c3551db0f31e0",
    "type": "commit",
    "url": "https://api.github.com/repos/scverse/anndata/git/commits/a4786471ee4d4e894fec150e426c3551db0f31e0"
  }
}

What part(s) of the article would you like to see updated?

Either the documentation for the ref path parameter needs to be updated or the ref API needs to start working with commits as documented.

Additional information

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    contentThis issue or pull request belongs to the Docs Content teamfix-internallyTriggers a workflow to copy the issue internally and close the current issuerestContent related to rest - overview.waiting for reviewIssue/PR is waiting for a writer's review

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions