microsoft / microsoft/azure-devops-python-api

append_log_content returns HTTP 400 (Content-Length not set)

未關閉
#419 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

主要語言
Python
星號
684
分支
218
平均合併
8 天 10 小時
30 天內合併 PR
1

描述

When using append_log_content, it returns HTTP 400 status code, and '{"count":55,"value":"ContentLength header must be specified to create a log."}'

DevOps: Azure DevOps Server 2020 update 1.1
azure-devops-python-api: 6.0.0b4

I workaround it with an explicit Content-Length header:

def append_log_content(self, content, scope_identifier, hub_name, plan_id, log_id):
        """AppendLogContent.
        :param bytes content: The content to be append
        :param str scope_identifier: The project GUID to scope the request
        :param str hub_name: The name of the server hub: "build" for the Build server or "rm" for the Release Management server
        :param str plan_id:
        :param int log_id:
        :rtype: :class:`<TaskLog> <azure.devops.v5_1.task.models.TaskLog>`
        """
        route_values = {}
        if scope_identifier is not None:
            route_values['scopeIdentifier'] = self._serialize.url('scope_identifier', scope_identifier, 'str')
        if hub_name is not None:
            route_values['hubName'] = self._serialize.url('hub_name', hub_name, 'str')
        if plan_id is not None:
            route_values['planId'] = self._serialize.url('plan_id', plan_id, 'str')
        if log_id is not None:
            route_values['logId'] = self._serialize.url('log_id', log_id, 'int')
        response = self._send(http_method='POST',
                              location_id='46f5667d-263a-4684-91b1-dff7fdcf64e2',
                              version='5.1',
                              route_values=route_values,
                              content=content,
                              media_type='application/octet-stream',
                              additional_headers={"Content-Length": len(content)})
        return self._deserialize('TaskLog', response)

貢獻指南

這個儲存庫沒有索引到貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

從 issue 中所示的 append_log_content 進入點開始,檢查其 _send 呼叫如何為 application/octet-stream 內容建構標頭。重現 Azure DevOps Server 2020 請求,然後確認該請求包含 Content-Length,且不再回傳 HTTP 400。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
azure, python
領域
api
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。