Skip to content

fix(c/driver_manager): handle long filenames instead of throwing - #4995

Merged
amoeba merged 4 commits into
apache:mainfrom
amoeba:cpp-filesystem-error-code
Nov 6, 2026
Merged

amoeba merged 4 commits into
apache:mainfrom
amoeba:cpp-filesystem-error-code

Conversation

@amoeba

@amoeba amoeba commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Copilot review on #4939 (comment) found an edge case in the C++ driver manager when strings that are too long to be valid operating-system-specific file paths are used. The current implementation uses the variant of std::filesystem::exists that throws and we weren't catching those.

This PR converts those uses to bool exists( const std::filesystem::path& p, std::error_code& ec ) noexcept; and either ignores the error or handles it an enhances the driver manager error.

This PR was detected with Copilot and I drove Opus 5.5 around. The changes were tested in CI, see comments in the PR thread.

@amoeba

amoeba commented Nov 5, 2026

Copy link
Copy Markdown
Member Author

I've pushed up just some tests that should exercise the edge case in 74fcf3d. I'll post the CI failures here once those run. I expect to see unhandled throws.

@amoeba

amoeba commented Nov 5, 2026

Copy link
Copy Markdown
Member Author

C/C++ (Conda/ubuntu-latest) failed with:

[ RUN      ] ConnectionProfiles.LongProfileFileName
/home/runner/work/arrow-adbc/arrow-adbc/c/driver_manager/adbc_driver_manager_test.cc:2199: Failure
Expected: status = AdbcDatabaseInit(&database.value, &error) doesn't throw an exception.
  Actual: it throws std::filesystem::__cxx11::filesystem_error with description "filesystem error: status: File name too long [/tmp/adbc_driver_manager_profile_test/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.toml]".

/home/runner/work/arrow-adbc/arrow-adbc/c/driver_manager/adbc_driver_manager_test.cc:2200: Failure
Expected equality of these values:
  status
    Which is: '\0'
  3

/home/runner/work/arrow-adbc/arrow-adbc/c/driver_manager/adbc_driver_manager_test.cc:2201: Failure
Value of: error.message
Expected: has substring "Could not access profile file /tmp/adbc_driver_manager_profile_test/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.toml: "
  Actual: NULL (of type char*)

[  FAILED  ] ConnectionProfiles.LongProfileFileName (0 ms)
[ RUN      ] ConnectionProfiles.LongProfileNameInSearchPath
/home/runner/work/arrow-adbc/arrow-adbc/c/driver_manager/adbc_driver_manager_test.cc:2215: Failure
Expected: status = AdbcDatabaseInit(&database.value, &error) doesn't throw an exception.
  Actual: it throws std::filesystem::__cxx11::filesystem_error with description "filesystem error: status: File name too long [/tmp/adbc_driver_manager_profile_test/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.toml]".

/home/runner/work/arrow-adbc/arrow-adbc/c/driver_manager/adbc_driver_manager_test.cc:2216: Failure
Expected equality of these values:
  status
    Which is: '\0'
  3

/home/runner/work/arrow-adbc/arrow-adbc/c/driver_manager/adbc_driver_manager_test.cc:2217: Failure
Value of: error.message
Expected: has substring "could not access /tmp/adbc_driver_manager_profile_test/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.toml ("
  Actual: NULL (of type char*)

[  FAILED  ] ConnectionProfiles.LongProfileNameInSearchPath (0 ms)

@amoeba

amoeba commented Nov 5, 2026

Copy link
Copy Markdown
Member Author

C/C++ (Conda/windows-latest) failed with:

[----------] 2 tests from DriverManagerFilesystemError
[ RUN      ] DriverManagerFilesystemError.LongNameInSearchPath
D:\a\arrow-adbc\arrow-adbc\c\driver_manager\adbc_driver_manager_test.cc(1462): error: Value of: error.message
Expected: has substring "could not access C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\adbc_filesystem_error_test\\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.toml ("
  Actual: 00000299DCE91400 pointing to "[Driver Manager] Could not load `xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`: LoadLibraryExW() failed: (126) The specified module could not be found.\r\n\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.dll: LoadLibraryExW() failed: (126) The specified module could not be found.\r\n\nAlso searched these paths for manifests:\n\tnot set: ADBC_DRIVER_PATH\n\tadditional search path: C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\adbc_filesystem_error_test\n\tnot enabled at build time: Conda prefix\n\tRegistry: HKEY_CURRENT_USER\\[Driver Manager] SOFTWARE\\ADBC\\DRIVERS not found\n\tdoes not exist: C:\\Users\\runneradmin\\AppData\\Local\\ADBC\\Drivers\n\tRegistry: HKEY_LOCAL_MACHINE\\[Driver Manager] SOFTWARE\\ADBC\\DRIVERS not found" (of type char * __ptr64)

and

[ RUN      ] ConnectionProfiles.LongProfileFileName
D:\a\arrow-adbc\arrow-adbc\c\driver_manager\adbc_driver_manager_test.cc(2202): error: Value of: error.message
Expected: has substring "Could not access profile file C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\adbc_driver_manager_profile_test\\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.toml: "
  Actual: 00000299DAFEAAE0 pointing to "[Driver Manager] Profile file does not exist: C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\adbc_driver_manager_profile_test\\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.toml" (of type char * __ptr64)
[  FAILED  ] ConnectionProfiles.LongProfileFileName (1 ms)
[ RUN      ] ConnectionProfiles.LongProfileNameInSearchPath
D:\a\arrow-adbc\arrow-adbc\c\driver_manager\adbc_driver_manager_test.cc(2219): error: Value of: error.message
Expected: has substring "could not access C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\adbc_driver_manager_profile_test\\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.toml ("
  Actual: 00000299DAFC82F0 pointing to "[Driver Manager] Profile not found: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nAlso searched these paths for profiles:\n\tADBC_PROFILE_PATH: C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\adbc_driver_manager_profile_test\n\tnot enabled at build time: Conda prefix\n\tuser config dir: C:\\Users\\runneradmin\\AppData\\Local\\ADBC\\Profiles" (of type char * __ptr64)

@amoeba

amoeba commented Nov 5, 2026

Copy link
Copy Markdown
Member Author

This didn't fail on Windows,

[ RUN      ] DriverManagerFilesystemError.LongNameAbsolutePath
[       OK ] DriverManagerFilesystemError.LongNameAbsolutePath (1 ms)

So I think std::filesystem on MSVC doesn't treat an overly long filename as an error, it just treats it as !exists.

@lidavidm

lidavidm commented Nov 5, 2026

Copy link
Copy Markdown
Member

Thanks, I had forgotten about this

@amoeba
amoeba marked this pull request as ready for review November 5, 2026 01:07
@amoeba
amoeba merged commit decc3da into apache:main Nov 6, 2026
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