microsoft / microsoft/azure-devops-python-api

Create_Attachment doesn't seem to work

Abierto
#322 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Lenguaje dominante
Python
Estrellas
684
Forks
218
Merge medio
8 d 10 h
PR fusionados (30 d)
1

Descripción

The python create_attachment call in the git client doesn't seem to work correctly. If you use it as currently implemented you get a 'azure.devops.exceptions.AzureDevOpsServiceError: Nullable object must have a value' exception.

I saw the example as part of issue 129: https://github.com/microsoft/azure-devops-python-api/issues/129 but that throws the same exception.

If I instead change the create_attachment call to:

def create_attachment(self, upload_stream, file_name, repository_id, pull_request_id, project=None, **kwargs):
        """CreateAttachment.
        [Preview API] Attach a new file to a pull request.
        :param object upload_stream: Stream to upload
        :param str file_name: The name of the file.
        :param str repository_id: The repository ID of the pull request’s target branch.
        :param int pull_request_id: ID of the pull request.
        :param str project: Project ID or project name
        :rtype: :class:`<Attachment> <azure.devops.v6_0.git.models.Attachment>`
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url('project', project, 'str')
        if file_name is not None:
            route_values['fileName'] = self._serialize.url('file_name', file_name, 'str')
        if repository_id is not None:
            route_values['repositoryId'] = self._serialize.url('repository_id', repository_id, 'str')
        if pull_request_id is not None:
            route_values['pullRequestId'] = self._serialize.url('pull_request_id', pull_request_id, 'int')
        if "callback" in kwargs:
            callback = kwargs["callback"]
        else:
            callback = None
        # content = self._client.stream_upload(upload_stream, callback=callback)
        response = self._send(http_method='POST',
                              location_id='965d9361-878b-413b-a494-45d5b5fd8ab7',
                              version='6.0-preview.1',
                              route_values=route_values,
                              content=upload_stream.read(),
                              media_type='application/octet-stream')
        return self._deserialize('Attachment', response)

things work.

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza por la implementación de create_attachment del cliente Git de Python y compárala con la solución alternativa mostrada en este issue y con el ejemplo del issue 129. Reproduce la excepción Nullable object must have a value y verifica después que el comportamiento corregido cree correctamente un adjunto de pull request.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
python
Área
api
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.