[Bug]: Late failed chunk PUT deletes a successful retry, causing final MOVE 400
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 45/100
Hướng nghiên cứu
Start with apps/dav/lib/Upload/UploadFolder.php, especially UploadFolder::createFile() and its exception cleanup, then inspect the storage behavior of File::put() and related upload tests. Reproduce the interleaving described in the issue and add a regression test showing that a failed PUT leaves a successful same-name retry available for assembly. Done means the regression passes while cleanup still handles partial data across storage implementations.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
A late failure in OCA\DAV\Upload\UploadFolder::createFile() can delete the final chunk already committed by another request retrying the same chunk name.
The retry returns 201 Created. When the original incomplete request eventually fails, its catch block looks up the chunk by name and deletes it. The final MOVE .../.file then returns 400 Bad Request because the stored chunks no longer add up to OC-Total-Length.
Verification scope
- Reproduced with real WebDAV requests on a downstream image based on official
nextcloud:34.0.2-apache. - Reproduced directly against Apache, without Traefik in the request path.
- A follow-up test sent the successful retry, final MOVE, and content download through Traefik HTTPS. The original incomplete request was sent directly to Apache to control its failure timing.
- Inspected official
v34.0.5,v35.0.2,v34.0.6rc1,v35.0.3rc1, and currentmasteron 2026-11-08. They retain this cleanup logic. - A focused PHP regression harness loading the unmodified
UploadFolder.phpfrom bothv34.0.5andv35.0.2also fails with “Late failure deleted the successful retry”. This harness simulates the interleaving using a Directory test double. - A complete deployment of the latest patch releases has not been tested. The live instance also includes an unrelated downstream
Directory::createFile()change to release upload locks in a finally block. Please distinguish the live reproduction from the focused newer-source regression tests.
Steps to reproduce
Use a disposable test account and an HTTP Apache upstream accessible from the test machine. Configure the origin as a trusted Nextcloud URL. No reverse proxy is required.
- Create a unique authenticated DAV upload collection.
- Start PUT A to chunk
1, declaring a 2 MiB Content-Length but initially sending only 8 KiB. Keep the connection open. - Send PUT B to the same chunk URL with a complete 2 MiB payload. Observe
201 Created. - End PUT A's request body early. Observe
400 Bad Request. - Send
MOVE <upload>/.filewithOC-Total-Length: 2097152and a Destination header.
Minimal Python 3 reproduction, using only the standard library. Set NC_URL to the local HTTP origin, for example http://localhost:8080, and NC_USER to a disposable test account. The password is prompted without echo. Only the uniquely named synthetic paths are cleaned up.
import base64
import getpass
import http.client
import os
import secrets
import socket
import time
from urllib.parse import quote, urlsplit
origin = os.environ["NC_URL"].rstrip("/")
url = urlsplit(origin)
assert url.scheme == "http", "Use the direct local Apache HTTP upstream"
user = quote(os.environ["NC_USER"], safe="")
password = getpass.getpass("Test account password/app password: ")
auth = "Basic " + base64.b64encode(
(os.environ["NC_USER"] + ":" + password).encode()
).decode()
session = "retry-repro-" + secrets.token_hex(8)
upload = url.path.rstrip("/") + "/remote.php/dav/uploads/" + user + "/" + session
target = url.path.rstrip("/") + "/remote.php/dav/files/" + user + "/" + session + ".bin"
destination = url.scheme + "://" + url.netloc + target
data = b"B" * (2 * 1024 * 1024)
def request(method, path, body=None, extra=None):
conn = http.client.HTTPConnection(url.hostname, url.port or 80, timeout=40)
headers = {
"Host": url.netloc,
"Authorization": auth,
"X-Requested-With": "XMLHttpRequest",
}
headers.update(extra or {})
conn.request(method, path, body=body, headers=headers)
response = conn.getresponse()
result = response.status, response.read()
conn.close()
return result
original = None
try:
status, body = request("MKCOL", upload, extra={
"Destination": destination, "Content-Length": "0",
})
assert status == 201, (status, body)
original = socket.create_connection((url.hostname, url.port or 80), timeout=40)
headers = (
f"PUT {upload}/1 HTTP/1.1\r\n"
f"Host: {url.netloc}\r\nAuthorization: {auth}\r\n"
f"Content-Length: {len(data)}\r\nConnection: close\r\n\r\n"
)
original.sendall(headers.encode() + b"A" * 8192)
time.sleep(1)
print("Complete retry:", request("PUT", upload + "/1", data)[0])
original.shutdown(socket.SHUT_WR)
reply = b""
while True:
block = original.recv(65536)
if not block:
break
reply += block
print("Original incomplete PUT:", reply.split(b"\r\n", 1)[0].decode())
print("Assembly:", request("MOVE", upload + "/.file", extra={
"Destination": destination, "OC-Total-Length": str(len(data)),
}))
finally:
if original is not None:
original.close()
request("DELETE", upload)
request("DELETE", target)
Actual behavior
Observed before changing UploadFolder cleanup, with a 2 MiB synthetic payload
Complete retry: 201
Original incomplete PUT: HTTP/1.1 400 Bad Request
Assembly: 400
Sabre\DAV\Exception\BadRequest
Chunks on server do not sum up to 2097152 but to 0 bytes
In a browser large-file upload we also observed successful chunk retries followed several minutes later by failures of the older PUTs, and finally MOVE 400.
Expected behavior
Failure cleanup must only remove data belonging to the failed attempt. A chunk already committed by a successful retry must remain available for final assembly.
Relevant implementation and local experiment
UploadFolder::createFile() catches the exception from the underlying Directory and, if a child with the requested name exists, deletes that child without establishing that the child belongs to the failed attempt. File::put() already manages per-attempt partial-file cleanup on the local storage path used here.
Removing that outer name-based deletion while allowing the original exception to propagate changed the same real HTTP test to
Complete retry: 201
Original incomplete PUT: HTTP/1.1 400 Bad Request
Assembly: 201
Download: 2097152 bytes, exactly matching the complete retry payload
SHA-256: 7995dfceebfb9fa8972d361d53d899f6e268ecd6d823b5737198041fabc02e20
This local experiment establishes the cleanup race on our storage path. Any upstream fix should also account for storage implementations with different partial-file behavior.
The affected method is present in these official sources.
Environment
- Live server version tested: 34.0.2, Apache-based downstream Docker image
- PHP: 8.5.9
- OS inside container: Debian GNU/Linux 13
- Database configuration: PostgreSQL (
dbtype=pgsql) - File locking: enabled, Redis
- Primary data: local filesystem exposed through a bind mount
- Server-side encryption: disabled
- Browser reproduction: Chrome, authenticated upload
- Upload settings during the affected browser test: 16 MiB chunks, maximum parallel count 2
- Existing recovery administrator used for the successful synthetic HTTP test. A separate temporary ordinary-user probe timed out during initial setup and is not counted as a successful reproduction.
- Full configuration, credentials, private hostnames, user identifiers, and user files are intentionally omitted.
Related reports searched
#65408 concerns public-share final assembly being interrupted and the web uploader deleting the session. #63071 concerns interrupted assembly and destination/filecache inconsistency. This report isolates an earlier server-side chunk PUT failure deleting a successful same-name retry before assembly.
Additional information
AI assistance was used to investigate the source, organize the reproduction, run the controlled tests, and draft this report. The HTTP results and before/after content comparison were observed on the affected instance. Newer releases were checked using source inspection and a focused regression harness as described above.
- Ngôn ngữ chính
- PHP
- Star
- 37.5k
- Fork
- 5.4k
- Merge trung bình
- 1 ngày 13 giờ
- Pull request đã merge (30 ngày)
- 639
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của nextcloud/server
-
35-feedback
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
0. Needs triage 35-feedback bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
Maintainer thường phản hồi trong vòng 1 ngày
-
workflowengine: File entity reuses the node of the first "Tag assigned" event for all later events in the same processCó thể đã có người làm @lazerg đã nhận 2 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Contacts import aborts with TypeError when vCards have no UID (TextImporter structure)Có thể đã có người làm @SebastianKrupinski đã nhận 6 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
nextcloud/server#66486 · 2 bình luận · 2 reaction · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Unified search: screen reader hears "No matching results" on mobile even when there are resultsCó thể đã có người làm @lazerg đã nhận 10 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của nextcloud/server
Issue tương tự
-
[Sync EN] stream: document the errors of the stream_context_*() and stream filter functions (#6091)Đang mởsync-en
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 79/100
Automattic/blocks-engine#6318 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Update: Laravel Cheat Sheet - middleware examples for the bootstrap/app.php layout (small update)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
OWASP/CheatSheetSeries#2990 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày