Skip to content

fix(httpd): return 400 when GET /user/dirs path is a file - #2292

Open
vulragrag-star wants to merge 1 commit into
drakkan:mainfrom
vulragrag-star:fix/user-dirs-file-path-2277
Open

vulragrag-star wants to merge 1 commit into
drakkan:mainfrom
vulragrag-star:fix/user-dirs-file-path-2277

Conversation

@vulragrag-star

Copy link
Copy Markdown

Checklist for Pull Requests


Problem

GET /api/v2/user/dirs?path=/file for an existing regular file returned HTTP 200 with a truncated [ body and closed the connection (curl: (52) Empty reply from server). Missing paths already returned 404; a file path was indistinguishable from a network failure.

Cause

OsFs.ReadDir / CryptFs.ReadDir open the path successfully even when it is a regular file, then fail on the first Readdir. streamJSONArray had already written status 200 and [, so the handler could only abort via http.ErrAbortHandler.

Fix

  • Stat the path in readUserFolder and return 400 when it is not a directory (same shape as getUserFile when the path is a directory).
  • Reject non-directories in local ReadDir implementations before returning a lister.

Tests

go test ./internal/vfs/ -run TestOsFsReadDirRejectsRegularFile -count=1

Fixes #2277

Stat the path before streaming directory JSON so a regular file no
longer yields HTTP 200 with a truncated "[" body (ErrAbortHandler).
Also reject non-directories in OsFs/CryptFs ReadDir so local backends
fail before the first Readdir call.

Fixes drakkan#2277
@CLAassistant

CLAassistant commented Sep 10, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: /api/v2/user/dirs closes the connection when the path is a regular file

2 participants