Detect directory paths in object get without recursive flag#3114
Open
Detect directory paths in object get without recursive flag#3114
Conversation
Copilot
AI
changed the title
[WIP] Fix ungraceful handling of object retrieval with directory path
Detect directory paths in object get without recursive flag
Feb 12, 2026
bbockelm
previously requested changes
Feb 21, 2026
d26575b to
8f8a4a8
Compare
Add a WithRejectCollections TransferOption that causes downloadObject to
verify (via PROPFIND) that the remote path is not a WebDAV collection
before attempting the download. When the remote path is a directory,
the transfer fails early with a clear error:
remote object is a directory; use recursive mode to download directories
The CLI's object get command sets WithRejectCollections(!isRecursive) so
that non-recursive downloads of directories produce a helpful error
instead of downloading an HTML directory listing.
To avoid an unnecessary PROPFIND round-trip, the collection check is
skipped when:
- sortAttempts already received a non-zero Age header from a cache
(cached objects are never directories), or
- a previous downloadObject call for the same job already confirmed
the path is not a collection (cached in TransferJob.notCollection).
If the URL contains a ?recursive query parameter that forces recursive
mode, rejectCollections is cleared in NewTransferJob so the check is
not applied.
Closes #1706
8f8a4a8 to
b828f65
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
pelican object getwithout recursive flag on directory paths creates empty files (via cache) or downloads HTML directory listings (direct from origin). This change detects directories during download and returns a clear error.Changes
client/handle_http.go: Added directory detection in the "worst case" HEAD request section ofdownloadHTTPRecursivefield totransferAttemptDetailsandtransferDetailsOptionsstructs to track contextcacheAge > 0(already confirmed as object from cache)text/htmlto detect XRootD directory listings"remote object is a directory but recursive is not enabled"client/fed_long_test.go: AddedtestObjectGetNonRecursiveDirPathtest caseThis approach follows the guidance to track knowledge as the download proceeds and only check for directories as a last resort when needed, avoiding unnecessary extra requests in most cases.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.