Skip to content

Octokit says that a tag does not exist when it does, in fact #1933

@astrohart

Description

@astrohart

Using LINQpad and OctoKit, for my testing repository, I have utilized the GitHub website to add a tag called 'v0.7.3' for testing purposes. The code

       /* Assuming the client variable is a GitHubClient that is properly authenticated and
          that repoOwner and repoName reference a repository to which I have full permissions */

	var refs = await client.Git.Reference.GetAll(repoOwner, repoName);
	refs.Select(r => r.Ref).Dump();
	return;

produces the result
image
Then, when I do

       /* Assuming the client variable is a GitHubClient that is properly authenticated and
          that repoOwner and repoName reference a repository to which I have full permissions */

        var refs = await client.Git.Reference.GetAll(repoOwner, repoName);
	
	foreach (var tagRef in refs)
	{
		if (!tagRef.Ref.Contains("v0.7.3"))
			continue;

		await client.Git.Reference.Delete(repoOwner,
			repoName, tagRef.Ref);
	}

Which should work, since the if branch does indeed let the loop move to the await client.Git.Reference.Delete line if I single-step, since tag matching the criteria does indeed exist (as has been shown above). However, upon calling await client.Git.Reference.Delete(...) on a tag that exists* I get the ApiValidationException shown
image
This counter-intuitive. Why is the API telling me my reference does not exist when it clearly does?

To reproduce:

  1. Sign in to GitHub.com website in any browser.
  2. Create a new Repo under your account with a README.md
  3. Alter the README.md and commit it
  4. Note the repo's name and your GitHub username
  5. In your browser, create a tag with whichever name you want
  6. Run the code in the second block above (with the appropriate authentication, repo owner, repo name, and tag search criteria.
  7. Note that the exception occurs.

Metadata

Metadata

Assignees

Labels

Type: MaintenanceAny dependency, housekeeping, and clean up Issue or PR

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions