Deleting Pull Request Attachments Prevents Reading Attachments
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 35/100
研究方向
從 delete_attachment_bug.py 以及 GitClient create_attachment 和 delete_attachment 呼叫開始,接著在 Python shell 中重現該序列。比較刪除後的請求和傳回的 attachment URL,以確定是用戶端還是 Azure DevOps API 導致了 FileIdNotFoundException。當原因已確定,且未刪除的 attachment 在該序列之後仍可讀取時,即表示完成。
由索引模型根據 Issue 內容生成。
描述
Hello,
I recently ran in to this issue while attempting to manage pull request attachments. It could be a bug with the AZDO API, but I'm specifically using azure-devops-python-api.
Steps to Reproduce
- Create multiple pull request attachments via
GitClient, and delete at least one. The specific order doesn't matter; you can create two attachments then delete one of them, or create a single attachment, delete it, and create a second attachment. - Attempting to access any non-deleted attachment (via the attachment URL) results in the following error:
{
"$id": "1",
"innerException": null,
"message": "TF400714: File ID 123456789 not found.",
"typeName": "Microsoft.TeamFoundation.Framework.Server.FileIdNotFoundException, Microsoft.TeamFoundation.Framework.Server",
"typeKey": "FileIdNotFoundException",
"errorCode": 0,
"eventId": 4005
}
Example Code
delete_attachment_bug.py
from azure.devops.v7_0.git.models import *
from azure.devops.v7_0.git.git_client import GitClient
from msrest.authentication import BasicAuthentication
from azure.devops.connection import Connection
from random import randint
import os
def fix_create_attachment(client: GitClient):
"""
See https://github.com/microsoft/azure-devops-python-api/issues/322 for documentation of this issue.
"""
def create_attachment(upload_stream, file_name, repository_id, pull_request_id, project=None):
route_values = {}
if project is not None:
route_values['project'] = client._serialize.url('project', project, 'str')
if file_name is not None:
route_values['fileName'] = client._serialize.url('file_name', file_name, 'str')
if repository_id is not None:
route_values['repositoryId'] = client._serialize.url('repository_id', repository_id, 'str')
if pull_request_id is not None:
route_values['pullRequestId'] = client._serialize.url('pull_request_id', pull_request_id, 'int')
# content = self._client.stream_upload(upload_stream, callback=callback)
response = client._send(http_method='POST',
location_id='965d9361-878b-413b-a494-45d5b5fd8ab7',
version='7.0',
route_values=route_values,
content=upload_stream.read(),
media_type='application/octet-stream')
return client._deserialize('Attachment', response)
client.create_attachment = create_attachment
pat = os.environ.get("mypersonalaccesstoken")
auth = BasicAuthentication("", pat)
connection = Connection("https://dev.azure.com/someorganization/", auth)
client: GitClient = connection.clients.get_git_client()
fix_create_attachment(client)
pr_id = 123456
project_id = "MyProject"
repo_id = "MyRepo"
def create_attachment():
with open("cool_pic.png", "rb") as file:
# Create random name for attachment
name = f"{randint(0,10000)}.png"
attachment: Attachment = client.create_attachment(file, name, repo_id, pr_id, project_id)
print(f"Created attachment: {name}\n(URL: {attachment.url})")
def delete_attachment(name):
client.delete_attachment(name, repo_id, pr_id, project_id)
print(f"Deleted attachment: {name}")
This code can be used along with the Python shell to reproduce the issue:
python -i delete_attachment_bug.py
>>> create_attachment()
>>> delete_attachment("nameFromPreviousCall")
>>> create_attachment()
Trying to access the most recently created attachment (via the attachment URL) results in the above error.
I'm using Python 3.7.4 and azure-devops==7.1.0b4.
I haven't been able to find a workaround yet. Note the example code includes a workaround for #322.
- 主要語言
- Python
- 星號
- 682
- 分支
- 218
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
microsoft/azure-devops-python-api 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 55/100
-
難度 5/5 一週以上 新手友好度 25/100
-
難度 1/5 1 小時以內 新手友好度 55/100
-
難度 4/5 3-5 天 新手友好度 35/100
-
難度 3/5 1-2 天 新手友好度 45/100
查看 microsoft/azure-devops-python-api 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 88/100
NousResearch/hermes-agent#133181 ·
維護者通常 1 天內回覆
-
[oblt-aw][security] SEC-022 — findings (2026-10-05)可能已有人在做 @elastic-vault-github-plugin-prod 今天認領。 未關閉oblt-aw/ai/fix-ready oblt-aw/detector/security oblt-aw/triage/security-secrets
難度 2/5 1-3 小時 新手友好度 68/100
elastic/oblt-aw#2304 · 2 則留言 · 1 個 reaction ·
維護者通常 1 天內回覆
-
難度 2/5 1 小時以內 新手友好度 90/100
huggingface/huggingface_hub#5083 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 64/100
deepset-ai/haystack#13107 ·
維護者通常 1 天內回覆
-
[Bug]: index worker dies on LOG_LEVEL=info / empty / numeric before it can report a missing bootstrap可能已有人在做 @sxh313 今天認領。 未關閉triage/confirmed
難度 2/5 1-3 小時 新手友好度 90/100
agentscope-ai/agentscope#3130 ·
維護者通常 1 天內回覆