Skip to content

[BUG] 分享 API (/api/share/create) 对已存在的路径始终返回 "must add at least 1 object" #2888

Description

@Mondoawa

Please confirm the following

  • I have read and agree to AGPL-3.0 Section 15 .
    The program is provided "as is" without any warranties; you bear all risks of using it.

  • I have read and agree to AGPL-3.0 Section 16 .
    The copyright holders and distributors are not liable for any damages resulting from the use or inability to use the program.

  • I confirm my description is clear, polite, helps developers quickly locate the issue, and complies with community rules.

  • I have read the OpenList documentation.

  • I confirm there are no duplicate issues or discussions.

  • I confirm this is an OpenList issue, not caused by other reasons (such as network, dependencies, or operation).

  • I believe this issue must be handled by OpenList and not by a third party.

  • I confirm this issue is not fixed in the latest version.

  • I have not read these checkboxes and therefore I just ticked them all, Please close this issue.

OpenList Version (required)

v4.2.4

Storage Driver Used (required)

OneDrive

Bug Description (required)

调用 /api/share/create 接口为已经存在的文件夹创建分享时,API 始终返回 400 错误,提示 must add at least 1 object,即使该路径下已有文件。

复现步骤:

  1. 使用有效的管理员 Token 进行认证(Authorization 头直接传 token,不加 Bearer 前缀)
  2. 调用 /api/fs/mkdir 创建测试目录,例如 /OneDrive/test-folder
  3. 调用 /api/fs/put 向该目录上传一个测试文件(mkdirput 均返回 200)
  4. 调用 /api/fs/list 验证文件已存在(返回文件列表,确认文件已上传)
  5. 调用 /api/share/create,请求体为 {"paths": ["/OneDrive/test"]}
  6. 返回 {"code":400,"message":"must add at least 1 object","data":null}

尝试过的变体:

  • paths 数组形式:{"paths": ["/OneDrive/..."]}
  • path 单数形式:{"path": "/OneDrive/..."}
  • 相对路径形式:{"paths": ["/test-folder"]}
  • 有文件的路径 vs 空文件夹路径

所有尝试均返回相同的 400 错误。

预期行为:
API 返回 200 状态码,并成功创建一个分享链接(返回 {"code":200,"message":"success","data":{"id":"xxx","url":"xxx"}}

实际行为:
API 返回 {"code":400,"message":"must add at least 1 object","data":null}

Logs (required)

root@VM686A290124C44C8:~#
curl -X POST http://localhost:5244/api/fs/mkdir
-H "Authorization: openlist-..." \
-H "Content-Type: application/json"
-d '{"path":"/OneDrive/test-floder"}'
{"code":200,"message":"success","data":null}
#创建目录

root@VM686A290124C44C8:~# curl -X POST http://localhost:5244/api/share/create
-H "Authorization: openlist-..." \
-H "Content-Type: application/json"
-d '{"paths":["/OneDrive/test-folder"]}'
{"code":400,"message":"must add at least 1 object","data":null}
#返回400

[GIN] 2026/08/01 - 15:23:28 | 200 | 1.66s | 127.0.0.1 | POST "/api/fs/mkdir"
[GIN] 2026/08/01 - 15:26:19 | 200 | 954.819µs | 127.0.0.1 | POST "/api/share/create"
#日志为200但终端执行返回确实400,且网页后端-分享界面不可见

Configuration File Content (required)

Image Image

Reproduction Link (optional)

No response

AI Generated Content (optional)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions