Skip to content

Fix non-ascii paths - #9452

Merged
cbielow merged 4 commits into
OpenMS:developfrom
cbielow:fix_utf8_path
Jun 5, 2026
Merged

cbielow merged 4 commits into
OpenMS:developfrom
cbielow:fix_utf8_path

Conversation

@cbielow

@cbielow cbielow commented Jun 5, 2026 •

Copy link
Copy Markdown
Contributor

Description

fix regression introduced in #8938 for filepaths on Windows containing non-ASCII characters (e.g. ä).

Also: fix missing copy of openms_thermo_bridged.dll to test's /bin folder (GENERATOR_IS_MULTI_CONFIG is a property, not a variable; needs translation) and potentially support more multi-config generators on Windows.

Checklist

  • Make sure that you are listed in the AUTHORS file
  • Add relevant changes and new features to the CHANGELOG file
  • I have commented my code, particularly in hard-to-understand areas
  • New and existing unit tests pass locally with my changes
  • Updated or added python bindings for changed or new classes (Tick if no updates were necessary.)

How can I get additional information on failed tests during CI

Click to expand If your PR is failing you can check out

Advanced commands (admins / reviewer only)

Click to expand
  • /reformat (experimental) applies the clang-format style changes as additional commit. Note: your branch must have a different name (e.g., yourrepo:feature/XYZ) than the receiving branch (e.g., OpenMS:develop). Otherwise, reformat fails to push.
  • setting the label "NoJenkins" will skip tests for this PR on jenkins (saves resources e.g., on edits that do not affect tests)
  • commenting with rebuild jenkins will retrigger Jenkins-based CI builds

⚠️ Note: Once you opened a PR try to minimize the number of pushes to it as every push will trigger CI (automated builds and test) and is rather heavy on our infrastructure (e.g., if several pushes per day are performed).

Summary by CodeRabbit

  • Bug Fixes

    • Improved Windows path handling with UTF-8 character support; now gracefully handles non-UTF-8 encoded input as a fallback.
  • Tests

    • Added comprehensive unit tests for path utilities, covering ASCII paths, UTF-8 input, and Windows-specific ANSI character handling.

@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

@cbielow The following names might be missing from the AUTHORS file:

  • Chris Bielow

Please consider applying the following patch:

--- AUTHORS	2026-06-05 09:49:50.529917471 +0000
+++ AUTHORS.new	2026-06-05 09:49:55.945726896 +0000
@@ -22,8 +22,8 @@
  - Chirag Dave
  - Chris Bauer
  - Chris Bielow
- - Christie Mathews
  - Christian Ehrlich
+ - Christie Mathews
  - Clemens Groepl
  - Cornelia Friedle
  - Daniel Jameson

@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR improves Windows Unicode path handling by updating OpenMS::to_path() with platform-aware UTF-8 conversion and a fallback mechanism for ANSI input, supported by CMake multi-config infrastructure improvements and validated with new unit tests.

Changes

Windows Unicode and Multi-Config Path Support

Layer / File(s) Summary
CMake Windows DLL-copy multi-config infrastructure
cmake/add_library_macros.cmake
copy_dll_to_extern_bin and openms_add_library macros are updated to retrieve GENERATOR_IS_MULTI_CONFIG via get_property and use $<CONFIG>-based destination paths for multi-config generators, ensuring proper DLL copying behavior.
PathUtils UTF-8 conversion with fallback
src/openms/include/OpenMS/SYSTEM/PathUtils.h
to_path(const std::string&) now handles UTF-8 conversion platform-specifically: Windows tries UTF-8-based path construction with std::system_error fallback to native code page paths; non-Windows always uses UTF-8 u8string. Documentation clarifies code page and fallback behavior.
PathUtils unit tests and registration
src/tests/class_tests/openms/executables.cmake, src/tests/class_tests/openms/source/PathUtils_test.cpp
PathUtils_test is registered in the CMake test list and introduces a comprehensive test suite validating ASCII and UTF-8 round-tripping, UTF-8 input handling, and Windows-specific ANSI-encoded input behavior without throwing.

Possibly related issues

🐰 In Windows paths we venture,
UTF-8 conversion now the signature feature,
DLL multi-config flows strong,
Tests ensure nothing goes wrong, ✨
Unicode handling, robust and long!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix non-ascii paths' directly addresses the main issue fixed in this PR: handling non-ASCII characters in file paths on Windows.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/openms/include/OpenMS/SYSTEM/PathUtils.h`:
- Around line 16-19: Add an `@brief` line to the Doxygen block in
src/openms/include/OpenMS/SYSTEM/PathUtils.h: replace the current free-form
comment that starts "Convert a UTF-8 std::string to std::filesystem::path safely
on all platforms." with a Doxygen-style comment that begins with "`@brief` Convert
a UTF-8 std::string to std::filesystem::path safely on all platforms." followed
by a blank line and then the existing details about Windows behavior and the
fallback for non-UTF-8 bytes; update the comment immediately above the
conversion helper in the OpenMS::PathUtils header so it conforms to the coding
guideline.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 103e275f-7592-4fc0-b3c9-4e481388cf7f

📥 Commits

Reviewing files that changed from the base of the PR and between a7c4fb3 and 01f35db.

📒 Files selected for processing (4)
  • cmake/add_library_macros.cmake
  • src/openms/include/OpenMS/SYSTEM/PathUtils.h
  • src/tests/class_tests/openms/executables.cmake
  • src/tests/class_tests/openms/source/PathUtils_test.cpp

Comment on lines 16 to +19
/// Convert a UTF-8 std::string to std::filesystem::path safely on all platforms.
/// On Windows, std::filesystem::path(std::string) uses the current code page, not UTF-8.
/// On Windows, std::filesystem::path(std::string) uses the current code page, not UTF-8,
/// so we explicitly construct from u8string. If the bytes are not valid UTF-8 (e.g., a
/// filename from argv in the ANSI code page), fall back to the native code page.

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.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Add @brief tag to Doxygen comment.

The Doxygen comment must start with @brief per coding guidelines.

📝 Proposed fix
-  /// Convert a UTF-8 std::string to std::filesystem::path safely on all platforms.
-  /// On Windows, std::filesystem::path(std::string) uses the current code page, not UTF-8,
-  /// so we explicitly construct from u8string. If the bytes are not valid UTF-8 (e.g., a
-  /// filename from argv in the ANSI code page), fall back to the native code page.
+  /// `@brief` Convert a UTF-8 std::string to std::filesystem::path safely on all platforms.
+  ///
+  /// On Windows, std::filesystem::path(std::string) uses the current code page, not UTF-8,
+  /// so we explicitly construct from u8string. If the bytes are not valid UTF-8 (e.g., a
+  /// filename from argv in the ANSI code page), fall back to the native code page.

As per coding guidelines: "Use Doxygen documentation with @brief (required), plus blank line, then details"

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/// Convert a UTF-8 std::string to std::filesystem::path safely on all platforms.
/// On Windows, std::filesystem::path(std::string) uses the current code page, not UTF-8.
/// On Windows, std::filesystem::path(std::string) uses the current code page, not UTF-8,
/// so we explicitly construct from u8string. If the bytes are not valid UTF-8 (e.g., a
/// filename from argv in the ANSI code page), fall back to the native code page.
/// `@brief` Convert a UTF-8 std::string to std::filesystem::path safely on all platforms.
///
/// On Windows, std::filesystem::path(std::string) uses the current code page, not UTF-8,
/// so we explicitly construct from u8string. If the bytes are not valid UTF-8 (e.g., a
/// filename from argv in the ANSI code page), fall back to the native code page.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/openms/include/OpenMS/SYSTEM/PathUtils.h` around lines 16 - 19, Add an
`@brief` line to the Doxygen block in
src/openms/include/OpenMS/SYSTEM/PathUtils.h: replace the current free-form
comment that starts "Convert a UTF-8 std::string to std::filesystem::path safely
on all platforms." with a Doxygen-style comment that begins with "`@brief` Convert
a UTF-8 std::string to std::filesystem::path safely on all platforms." followed
by a blank line and then the existing details about Windows behavior and the
fallback for non-UTF-8 bytes; update the comment immediately above the
conversion helper in the OpenMS::PathUtils header so it conforms to the coding
guideline.

@jpfeuffer jpfeuffer 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.

looks correct. good to go if CI passes

@cbielow
cbielow enabled auto-merge (squash) June 5, 2026 09:57
@timosachsenberg

Copy link
Copy Markdown
Contributor

thanks!

@cbielow
cbielow merged commit d8fd0a0 into OpenMS:develop Jun 5, 2026
15 checks passed
@timosachsenberg timosachsenberg mentioned this pull request Jun 8, 2026
timosachsenberg added a commit that referenced this pull request Jul 9, 2026
… external CMakeLists to LF

- Remove external tracker/issue references (#9460 §1, #9452, #9204, #9075, Lxx)
  from added test comments; comments now describe the durable behavior under test.
- Normalize src/tests/external/CMakeLists.txt to LF (matches .gitattributes eol=lf),
  which also clears the trailing-whitespace (CR) that git diff --check flagged.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
timosachsenberg added a commit that referenced this pull request Jul 10, 2026
…only config, downstream Qt contract (#9460) (#9603)

* [TEST] Infrastructure (§1): non-ASCII paths, exit-code mapping, read-only config, downstream Qt contract (#9460)

Close the remaining §1 [AUTO] gaps of the OpenMS 3.6.0 pre-release testing plan (#9460). Tests only.

- PathUtils_test: Windows-only UNC + ANSI-codepage to_path() cases under #ifdef _WIN32 (L35).
- TOPP FileConverter: read AND write through a non-ASCII (UTF-8) path, materialized at test time
  via `cmake -E copy` (the permanent #9452 regression) (L37).
- File_test: pin the "siblings only, no PATH fallback" contract of findSiblingTOPPExecutable
  (its TODO / #9204) plus a negative findExecutable case (L40).
- THIRDPARTY: assert a present-but-failing external program returns EXTERNAL_PROGRAM_ERROR (9),
  distinct from the EXTERNAL_PROGRAM_NOTFOUND (14) of a missing binary (L41).
- UpdateCheck_test (new): an unwritable config dir logs a warning and returns gracefully -- no
  network request, no crash (the $HOME-not-writable fix #9075) (L45).
- external/: a second downstream target that finds Qt6 itself and links Qt6::Core, proving
  OpenMS exports no transitive Qt6 (L56).

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* [TEST] Make CometAdapter failing-executable test portable

* [TEST] Address review: drop tracker IDs from test comments, normalize external CMakeLists to LF

- Remove external tracker/issue references (#9460 §1, #9452, #9204, #9075, Lxx)
  from added test comments; comments now describe the durable behavior under test.
- Normalize src/tests/external/CMakeLists.txt to LF (matches .gitattributes eol=lf),
  which also clears the trailing-whitespace (CR) that git diff --check flagged.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

---------

Co-authored-by: Claude Opus 4.8 <[email protected]>
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