microsoft / microsoft/azure-devops-python-api

'dict' object has no attribute 'ids'

Open
#502 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
684
Forks
218
Avg merge
8d 10h
Merged PRs (30d)
1

Description

Hi i'm trying to list all the commit in a specific branch via python from azure devops but getting this error, 'dict' object has no attribute 'ids'. I'm using get_commits function here is my sample code.

import os
from azure.devops.connection import Connection
from msrest.authentication import BasicAuthentication
from git import Repo, GitCommandError

class AzureDevOpsGitManager:
    def __init__(self, organization, project, repo_name, pat):
        self.organization = organization
        self.project = project
        self.repo_name = repo_name
        self.credentials = BasicAuthentication('', pat)
        self.connection = Connection(base_url=f'https://dev.azure.com/{organization}', creds=self.credentials)
        self.git_client = self.connection.clients.get_git_client()
      
    def list_commits(self, branch_name='main'):
        commits = self.git_client.get_commits(repository_id=self.repo_name, project=self.project_name, search_criteria={'itemVersion': {'version': branch_name}})
        return [(commit.commit_id, commit.author.name, commit.comment) for commit in commits]

Any idea why i'm getting the above error.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in list_commits and compare the get_commits call with the Azure DevOps Python API response shape, especially the search_criteria argument and the use of project_name versus project. Reproduce the error with the shown example and inspect the returned value before iterating it. Done means the branch commits can be listed with commit_id, author.name, and comment without the attribute error.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, git, python
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.