404 and other errors when calling `delete()` method on `Github.Secret.Secret` and `GitHub.Variable.Variable`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.8k
- Forks
- 1.9k
- Avg merge
- 17m
- Merged PRs (30d)
- 2
Description
Methods called on Secret and Variable model methods are not requesting the correct GitHub REST API endpoint URLs. Invoking these methods causes 404 errors.
- For
Variable, there is a bug that appends additional incorrect parts to the variable's REST API endpoint URL, resulting in 404 errors fordelete(HTTPDELETE) andedit(HTTPPATCH).- Example:
- Expected:
/repos/{owner}/{repo}/actions/variables/{name} - Actual:
/repos/{owner}/{repo}/actions/variables/{name}/actions/variables/{name}
- Expected:
- Example:
- For both
VariableandSecret, fetching aPaginatedListof either from theRepositorymodel'sget_variablesorget_secretsmethods fails to correctly set the_urlattribute on the paginated list of models. Therefore, calling such methods will also fail.
Below are some examples for how to reproduce the unexpected behavior. Please substitute "AndrewJDawes/PyGithub" with the owner/name of a repository to which you have access.
# Setup
repo = self.g.get_repo("AndrewJDawes/PyGithub")
variable = repo.create_variable("VARIABLE_NAME", "VARIABLE_VALUE")
repo = self.g.get_repo("AndrewJDawes/PyGithub")
variable = repo.get_variable("VARIABLE_NAME")
# Issue
variable.delete() # github.GithubException.UnknownObjectException: 404 {"message": "Not Found", "documentation_url": "https://docs.github.com/rest"}
repo = self.g.get_repo("AndrewJDawes/PyGithub")
repo.create_variable("VARIABLE_ONE_NAME", "VARIABLE_ONE_VALUE")
repo.create_variable("VARIABLE_TWO_NAME", "VARIABLE_TWO_VALUE")
repo = self.g.get_repo("AndrewJDawes/PyGithub")
variables = repo.get_variables()
for variable in variables:
if variable.name in ["VARIABLE_ONE_NAME", "VARIABLE_TWO_NAME"] and variable.value in ["VARIABLE_ONE_VALUE", "VARIABLE_TWO_VALUE"]:
variable.delete() # Fails to delete Variable
repo = self.g.get_repo("AndrewJDawes/PyGithub")
repo.create_secret("SECRET_ONE_NAME", "SECRET_ONE_VALUE")
repo.create_secret("SECRET_TWO_NAME", "SECRET_TWO_VALUE")
repo = self.g.get_repo("AndrewJDawes/PyGithub")
secrets = repo.get_secrets()
for secret in secrets:
if secret.name in ["SECRET_ONE_NAME", "SECRET_TWO_NAME"]:
secret.delete() # AttributeError: 'NoneType' object has no attribute 'startswith'
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Secret and Variable model methods and the Repository.get_variables and get_secrets entry points. Reproduce the listed delete and edit failures, then compare the generated REST URLs and paginated model _url values with the expected endpoints. Done means these operations work for individual and paginated Secret and Variable objects.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- github, python
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100