Skip to content

Add support for Dropbox team folders with path-root header#217

Open
neon-ninja wants to merge 5 commits intodropbox:masterfrom
UoA-eResearch:master
Open

Add support for Dropbox team folders with path-root header#217
neon-ninja wants to merge 5 commits intodropbox:masterfrom
UoA-eResearch:master

Conversation

@neon-ninja
Copy link
Copy Markdown

This pull request improves the handling of Dropbox root namespaces to ensure team folders are accessible and enhances the ls command's behavior for file and folder detection. The most important changes are grouped below:

Dropbox root namespace auto-detection:

  • Added logic in initDbx (in cmd/root.go) to automatically detect and set the Dropbox root namespace header for non-admin tokens, making team folders accessible by default. This involves calling users.GetCurrentAccount and setting the Dropbox-API-Path-Root header based on the user's or team's root namespace.
  • Added new imports for users and common packages to support root namespace detection.

Enhancements to the ls command:

  • Updated the ls command in cmd/ls.go to check if the provided path exists and is a file (except for the root path), improving error handling and output formatting for file listings. [1] [2]

General improvements:

  • Minor whitespace and formatting adjustments for clarity and consistency.

Copilot AI and others added 5 commits March 17, 2026 21:10
…der support

Co-authored-by: neon-ninja <3378822+neon-ninja@users.noreply.github.com>
…path-root flag

Co-authored-by: neon-ninja <3378822+neon-ninja@users.noreply.github.com>
… on root path

Co-authored-by: neon-ninja <3378822+neon-ninja@users.noreply.github.com>
…-root-header

Auto-detect root namespace to support Dropbox team folders via Dropbox-API-Path-Root header
Copilot AI review requested due to automatic review settings March 17, 2026 22:32
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 17, 2026

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ neon-ninja
❌ Copilot
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the CLI’s Dropbox client initialization to automatically set the Dropbox-API-Path-Root header (so Dropbox Business team folders are accessible by default), and adjusts ls to better distinguish file vs folder paths (especially for root).

Changes:

  • Auto-detect root namespace via users.GetCurrentAccount and set Dropbox-API-Path-Root for non-teamManage tokens.
  • Update ls to avoid calling get_metadata for the root path and to short-circuit when the target is a file.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
cmd/root.go Adds root-namespace auto-detection and configures Dropbox-API-Path-Root header generation.
cmd/ls.go Improves file-vs-folder detection (and avoids root-path get_metadata errors).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

printItem(formatFileMetadata(f, long))
err = w.Flush()
return err
}
usersClient := users.New(config)
account, accountErr := usersClient.GetCurrentAccount()
if accountErr != nil {
config.LogInfo("Warning: could not auto-detect root namespace (%v); team folders may not be accessible", accountErr)
Comment on lines +231 to +234
pathRootHeader := fmt.Sprintf(`{".tag": "root", "root": "%s"}`, rootNamespaceID)
config.HeaderGenerator = func(_, _, _, _ string) map[string]string {
return map[string]string{"Dropbox-API-Path-Root": pathRootHeader}
}
Comment on lines +218 to +236
usersClient := users.New(config)
account, accountErr := usersClient.GetCurrentAccount()
if accountErr != nil {
config.LogInfo("Warning: could not auto-detect root namespace (%v); team folders may not be accessible", accountErr)
} else {
var rootNamespaceID string
switch ri := account.RootInfo.(type) {
case *common.TeamRootInfo:
rootNamespaceID = ri.RootNamespaceId
case *common.UserRootInfo:
rootNamespaceID = ri.RootNamespaceId
}
if rootNamespaceID != "" {
pathRootHeader := fmt.Sprintf(`{".tag": "root", "root": "%s"}`, rootNamespaceID)
config.HeaderGenerator = func(_, _, _, _ string) map[string]string {
return map[string]string{"Dropbox-API-Path-Root": pathRootHeader}
}
}
}
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.

4 participants