files_external occ commands crash with InvalidArgumentException for SMB mounts without credentials

未关闭 适合新手
#67,534 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
78/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
php
领域
backend, cli

调研方向

阅读 apps/files_external/lib/Command/StorageAuthBase.php 中 createStorage() 附近的代码,以及相关的 SMB 后端代码,追踪缺少凭据时的处理方式。添加所要求的 InvalidArgumentException 处理和单元测试,然后运行相关测试。完成标准是:在没有凭据的情况下挂载 SMB 时,命令打印“Username and/or password required”,而不是原始异常。

由索引模型根据 Issue 内容生成。

描述

bug feature: external storage feature: occ good first issue
Bug description

StorageAuthBase::createStorage() (used by files_external:notify and files_external:verify) only catches InsufficientDataForMeaningfulAnswerException and StorageNotAvailableException around manipulateStorageConfig():

https://github.com/nextcloud/server/blob/3a68340a6c806a18cdd0d9667a3b9ec5f096b135/apps/files_external/lib/Command/StorageAuthBase.php#L89-L96

The SMB backend throws an InvalidArgumentException when no user or password is available:

https://github.com/nextcloud/server/blob/3a68340a6c806a18cdd0d9667a3b9ec5f096b135/apps/files_external/lib/Lib/Backend/SMB.php#L65-L69

So for an SMB mount using login credentials (or without stored credentials) run without -u/-p, occ shows a raw exception instead of the intended "Username and/or password required" message (see the first log in #59519).

Steps to reproduce

Found by code reading.

  1. Create an SMB mount with "Log-in credentials, save in session".
  2. Run occ files_external:notify <mount_id> without -u/-p.
  3. An InvalidArgumentException: user or password is not set is printed.
Expected behavior

The command prints "Username and/or password required". Fix: also catch \InvalidArgumentException in the backend manipulateStorageConfig() block of StorageAuthBase::createStorage() and set $noAuth = true, with a unit test.

Nextcloud version

master

主要语言
PHP
星标
37.6k
派生
5.4k
平均合并
1 天 20 小时
30 天内合并 PR
605

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

nextcloud/server 的其他 Issue

查看 nextcloud/server 的全部 Issue

相似的 Issue

更多 PHP Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。