microsoft / microsoft/azure-devops-python-api
AttributeError: 'dict' object has no attribute 'version_type' when trying to use git_client.get_commits search_criteria
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 684
- Forks
- 218
- Avg merge
- 8d 10h
- Merged PRs (30d)
- 1
Description
When trying to get all the commits on a branch I get an attribute error.
Code:
from azure.devops.connection import Connection
from azure.devops.v7_0.git import GitClient
from azure.devops.v7_0.git.models import GitQueryCommitsCriteria
from msrest.authentication import BasicAuthentication
cm_search_criteria = GitQueryCommitsCriteria(
item_version={"version": branch_name,"versionType": 'branch'}
)
print (f"search critera")
print (cm_search_criteria)
print (f"search critera")
commits = git_client.get_commits(
repo_name,
project=project_name,
search_criteria=cm_search_criteria
)
Results:
Traceback (most recent call last):
File "C:\PythonWork\Tool Connectivity\ADO_ALL_REPOS_BRANCHES_COMMITS.py", line 66, in
commits = git_client.get_commits(
repo_name,
project=project_name,
search_criteria=cm_search_criteria
)
File "C:\Users\tmoran\AppData\Local\Programs\Python\Python313\Lib\site-packages\azure\devops\v7_0\git\git_client_base.py", line 361, in get_commits
if search_criteria.item_version.version_type is not None:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'dict' object has no attribute 'version_type'
I cannot see anything wrong with the code, but it is throwing an error, does any one see an error?
Contributor guide
No contributing guide indexed for this repository
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 azure/devops/v7_0/git/git_client_base.py around line 361 and the GitQueryCommitsCriteria model used by get_commits. Compare the expected item_version model shape with the dictionary supplied in the example. Done means the branch criteria can be passed to get_commits without the AttributeError and the commit query completes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, python
- Domain
- api, devops
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100