Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 13, 2026

SFTP integration tests were failing with "No such file" errors due to incorrect path handling in chrooted environments where the server restricts users to a specific directory tree.

Changes

  • Test setup: Handle empty SFTP_TEST_ROOT environment variable correctly - empty string now uses relative paths instead of defaulting to /tmp/sharpsync-tests
  • Exception handling: Catch SftpPathNotFoundException in addition to SftpPermissionDeniedException during directory creation and initialization
  • Chroot detection: Simplify logic to assume relative paths when RootPath doesn't start with "/", which correctly identifies chrooted servers

Example

// Before: Empty SFTP_TEST_ROOT defaulted to absolute path
_testRoot = Environment.GetEnvironmentVariable("SFTP_TEST_ROOT") ?? "/tmp/sharpsync-tests";

// After: Explicitly check for null to distinguish empty string (chroot) from unset
var testRootEnv = Environment.GetEnvironmentVariable("SFTP_TEST_ROOT");
_testRoot = testRootEnv ?? "/tmp/sharpsync-tests";

The CI test environment uses SFTP_TEST_ROOT="" to indicate a chrooted setup, but the code was treating this the same as an unset variable.


💡 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.

Copilot AI and others added 2 commits January 13, 2026 22:44
- Handle empty SFTP_TEST_ROOT properly (use relative path instead of /tmp/sharpsync-tests)
- When root is empty string (chrooted env), use relative paths for test directories
- This fixes "No such file" errors when creating test directories in CI

Co-authored-by: Menelion <595597+Menelion@users.noreply.github.com>
- Simplify chroot detection: assume relative paths when RootPath doesn't start with "/"
- Fix exception handling to catch SftpPathNotFoundException in addition to permission errors
- This should fix issues with chrooted SFTP environments in CI
- Separate chroot detection from root path creation logic

Co-authored-by: Menelion <595597+Menelion@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix CI integration and resolve test failures Fix SFTP test failures in chrooted environments Jan 13, 2026
Copilot AI requested a review from Menelion January 13, 2026 22:56
@Menelion Menelion marked this pull request as ready for review January 13, 2026 23:05
@Menelion Menelion merged commit 7c0a42d into dev-vs-ci Jan 13, 2026
@Menelion Menelion deleted the copilot/sub-pr-32 branch January 13, 2026 23:06
Menelion added a commit that referenced this pull request Jan 14, 2026
* Try to reconcile dev with CI and fix tests finally

* Fix CS

* Try fixing workflow

* More fixes

* Meow

* Meow2

* Meow3

* Meow4

* Meow5

* meow6

* meow7

* Meow8

* Meow9

* meow11

* Meow12

* meow13

* meow14

* Meow10

* meow15

* meow16

* meow17

* meow18

* meow19

* meow20

* meow21

* meow22

* meow23

* meow23

* meow24

* meow25

* meow26

* meow27

* Fix SFTP test failures in chrooted environments (#33)

* Initial plan

* Fix SFTP test root path handling for chrooted environments

- Handle empty SFTP_TEST_ROOT properly (use relative path instead of /tmp/sharpsync-tests)
- When root is empty string (chrooted env), use relative paths for test directories
- This fixes "No such file" errors when creating test directories in CI

Co-authored-by: Menelion <595597+Menelion@users.noreply.github.com>

* Improve SFTP chroot detection and path handling

- Simplify chroot detection: assume relative paths when RootPath doesn't start with "/"
- Fix exception handling to catch SftpPathNotFoundException in addition to permission errors
- This should fix issues with chrooted SFTP environments in CI
- Separate chroot detection from root path creation logic

Co-authored-by: Menelion <595597+Menelion@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Menelion <595597+Menelion@users.noreply.github.com>

* Fix whitespace formatting in SftpStorageTests.cs (#34)

* Initial plan

* Fix whitespace formatting in SftpStorageTests.cs

Co-authored-by: Menelion <595597+Menelion@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Menelion <595597+Menelion@users.noreply.github.com>

* Fix SFTP integration tests by configuring writable chroot directory (#35)

* Initial plan

* Fix SFTP test configuration for chrooted environment

- Change SFTP container to use command array format for proper parsing
- Set SFTP_TEST_ROOT to "upload" directory which is writable by test user
- Remove volume mount that was causing permission issues
- The atmoz/sftp image chroots users and only specified directories are writable
- This fixes "No such file" errors when SFTP tests try to create directories

Co-authored-by: Menelion <595597+Menelion@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Menelion <595597+Menelion@users.noreply.github.com>

* Fix WebDAV GetRelativePath to handle full URLs from server responses (#36)

* Initial plan

* Fix WebDavStorage GetRelativePath to correctly strip root path from WebDAV resource URLs

Co-authored-by: Menelion <595597+Menelion@users.noreply.github.com>

* Fix WebDavStorage GetRelativePath to handle full URLs from WebDAV server

Co-authored-by: Menelion <595597+Menelion@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Menelion <595597+Menelion@users.noreply.github.com>

* Fix CS

* Fix WebDAV CreateDirectoryAsync to ensure root path exists before creating subdirectories

CreateDirectoryAsync was missing the call to EnsureRootPathExistsAsync that
WriteFileAsync already had. This caused integration tests to fail because each
test uses a unique root path (containing a GUID for isolation), and attempting
to create subdirectories like "test/subdir" would fail with 409 Conflict when
the root path itself didn't exist yet.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Remove garbage

---------

Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
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.

2 participants