Skip to content

object/sftp: fix endpoint parsing for path colons - #7406

Merged
jiefenghuang merged 3 commits into
mainfrom
sftp-endpoint-parsing
Aug 19, 2026
Merged

object/sftp: fix endpoint parsing for path colons#7406
jiefenghuang merged 3 commits into
mainfrom
sftp-endpoint-parsing

Conversation

@zhijian-pro

Copy link
Copy Markdown
Contributor

No description provided.

@zhijian-pro

Copy link
Copy Markdown
Contributor Author
格式 修复前 修复后
host:/path ✅ 默认端口 22,路径 /path ✅ 保持不变
host:relative/path ✅ 默认端口 22,相对路径 ✅ 保持不变
host:2022:/path ✅ 端口 2022,路径 /path ✅ 保持不变
host:2022:relative/path ✅ 端口 2022,相对路径 ✅ 保持不变
host:2022/path ⚠️ 不报错,但按端口 22、路径 2022/path 解析 ❌ 报缺少端口与路径之间的冒号
host:/path/T05:53:21 too many colons in address ✅ 端口 22,时间戳完整保留
host:2022:/path/T05:53:21 too many colons in address ✅ 端口 2022,时间戳完整保留
host:2022/path/T05:53:21 too many colons in address ❌ 明确报 missing colon between port and path
[2001:db8::1]:/path ✅ IPv6,默认端口 22 ✅ 保持不变
[2001:db8::1]:2022:/path ✅ IPv6,端口 2022 ✅ 保持不变
[2001:db8::1]:2022/path ⚠️ 不报错,但按端口 22、路径 2022/path 解析 ❌ 明确报缺少冒号
[2001:db8::1]:/path/T05:53:21 ❌ 路径冒号导致解析失败 ✅ 默认端口 22,时间戳完整保留
[2001:db8::1]:2022:/path/T05:53:21 ❌ 路径冒号导致解析失败 ✅ 端口 2022,时间戳完整保留
[2001:db8::1]:2022/path/T05:53:21 ❌ 路径冒号导致解析失败 ❌ 明确报 missing colon between port and path
host:/path/T05%3A53%3A21 %3A 作为远端文件名的字面量 ✅ 保持不变,仍不会解码成冒号

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Improves SFTP endpoint parsing for custom ports, IPv6 hosts, and timestamped paths.

Changes:

  • Extracts endpoint parsing into a dedicated helper.
  • Adds table-driven parser tests.
  • Documents supported SFTP formats in English and Chinese.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
pkg/object/sftp.go Implements endpoint parsing.
pkg/object/object_storage_test.go Tests endpoint formats and errors.
docs/en/guide/sync.md Documents SFTP syntax.
docs/zh_cn/guide/sync.md Adds corresponding Chinese documentation.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread pkg/object/sftp.go Outdated
Only treat a numeric field before the path separator as an explicit SSH port, so relative paths containing colons remain valid path names. Add parser coverage for IPv6 default ports and relative timestamped paths.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Treat empty SFTP endpoint paths as invalid instead of letting filepath.Clean turn them into '.', and add parser coverage for empty paths and unusual relative path names.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@codecov

codecov Bot commented Aug 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 42 lines in your changes missing coverage. Please review.
✅ Project coverage is 40.94%. Comparing base (a617e1b) to head (618f71c).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
pkg/object/sftp.go 0.00% 42 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7406      +/-   ##
==========================================
+ Coverage   34.44%   40.94%   +6.49%     
==========================================
  Files         140      178      +38     
  Lines       48323    58902   +10579     
==========================================
+ Hits        16645    24115    +7470     
- Misses      29995    31851    +1856     
- Partials     1683     2936    +1253     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jiefenghuang jiefenghuang changed the title sync: SFTP endpoint parsing for custom ports and timestamped paths object/sftp: fix endpoint parsing for path colons Aug 19, 2026
@jiefenghuang
jiefenghuang merged commit 802b2f4 into main Aug 19, 2026
35 checks passed
@jiefenghuang
jiefenghuang deleted the sftp-endpoint-parsing branch August 19, 2026 04:33
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.

3 participants