Skip to content

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

Closed

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

  1. added
    contentThis issue or pull request belongs to the Docs Content team
    on Mar 1, 2024
  2. welcome commented on Mar 1, 2024

    @welcome

    Thanks for opening this issue. A GitHub docs team member should be by to give feedback soon. In the meantime, please check out the contributing guidelines.

  3. added
    triageDo not begin working on this issue until triaged by the team
    on Mar 1, 2024
  4. nguyenalex836 commented on Mar 1, 2024

    @nguyenalex836
    Contributor

    @flying-sheep Thanks for opening this issue! I'll get this triaged for review ✨

  5. added
    waiting for reviewIssue/PR is waiting for a writer's review
    restContent related to rest - overview.
    and removed
    triageDo not begin working on this issue until triaged by the team
    on Mar 1, 2024
  6. added
    fix-internallyTriggers a workflow to copy the issue internally and close the current issue
    on Mar 4, 2024
  7. docs-bot commented on Mar 4, 2024

    @docs-bot
    Collaborator

    Thank you for opening this issue! Updates to this documentation must be made internally. I have copied your issue to an internal issue, so I will close this issue.

  8. flying-sheep commented on Mar 5, 2024

    @flying-sheep
    Author

    What will the fix be? Will the definition of the ref parameter change or the behavior of the API? Where can I track this?

  9. lsdm83114 commented on Mar 5, 2024

    @lsdm83114
  10. lsdm83114 commented on Mar 5, 2024

    @lsdm83114
  11. flying-sheep commented on Mar 15, 2024

    @flying-sheep
    Author

    The documentation now reads

    ref string Required

    The Git reference. For more information, see "Git References" in the Git documentation.

    So I assume that means “commit sha” isn’t supposed to be a valid option?

    Can you please clarify what the resolution here is?

  12. skedwards88 commented on Mar 15, 2024

    @skedwards88
    Contributor

    The description for that endpoint says

    The :ref in the URL must be formatted as heads/ for branches and tags/ for tags. If the :ref doesn't match an existing ref, a 404 is returned.

    So I think that the SHA is not accepted. I'll open an internal issue to move that info into the ref parameter description to make it more discoverable.

  13. flying-sheep commented on Mar 16, 2024

    @flying-sheep
    Author

    Thank you! I think the endpoint description you quote stayed the same, but the parameter description already changed since I filed this:

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

    I opened this initially since I read both endpoint and parameter descriptions and found them at odds. I also used a third party GitHub API client that followed the parameter docs and offered an abstraction for the commit case.

    I’m just confused why there’s nobody from GitHub responding in this thread confirming that the change in the docs means that it was a mistake that one option for “ref” was a commit SHA. I guess it’s safe to infer that it is, but it would be nice to have feedback in a public issue 😄

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