Skip to content

[Feature] Loading XML from remote locations (S3, HTTP/FTP) - #8671

Closed
timosachsenberg wants to merge 5 commits into
OpenMS:developfrom
timosachsenberg:feature/remoteXML
Closed

timosachsenberg wants to merge 5 commits into
OpenMS:developfrom
timosachsenberg:feature/remoteXML

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Jan 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR adds support for loading XML files (mzML, etc.) from remote locations:

  • S3 via AWS SDK (when WITH_S3=ON)
  • HTTP/HTTPS/FTP via Xerces NetAccessor (requires Xerces compiled with libcurl support)

Features:

  • Chunked streaming to avoid loading entire files into memory
  • On-the-fly decompression support for gzip and bzip2 compressed files
  • Automatic compression detection via magic bytes or Content-Encoding header

Changes from original PR #7297

This PR is rebased on current develop and includes fixes for:

  • Build system: S3 code now conditionally compiled only when WITH_S3=ON
  • Memory safety: Fixed throw new → throw, memory leaks, AWS SDK lifecycle
  • Error handling: parseS3Uri_() now throws on invalid URI instead of silent failure
  • Code quality: Consistent logging, removed redundant fetches, fixed typos

Test plan

  • Build with WITH_S3=OFF (default) - should compile without AWS SDK
  • Build with WITH_S3=ON - requires AWS SDK installed
  • Test S3 loading with valid AWS credentials
  • Test HTTP/FTP loading (requires Xerces with network support)

TODO

  • Support Indexed MzML for S3

Based on work by @jpfeuffer in #7297.

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • New Features

    • Added optional S3 loading support for s3:// URIs (including streamed, chunked access).
    • Added automatic decompression for gzipped and bzip2-compressed S3 objects.
    • Improved remote file handling for XML/MzML inputs over HTTP/HTTPS/FTP (and S3 when enabled).
  • API Changes

    • Updated loaded-file metadata handling: introduced direct “network path” support and strengthened setLoadedFileType to use FileTypes::Type.
  • Bug Fixes

    • Avoided extension/content mismatch checks for remote URLs during fatal error reporting.
  • Tests

    • Added S3-backed MzML load tests (enabled when S3 support is built).

jpfeuffer and others added 2 commits January 15, 2026 23:51
…de quality

Build system fixes:
- Conditionally compile S3 sources only when WITH_S3=ON (sources.cmake)
- Add #ifdef WITH_S3 guards to S3InputSource.h and S3ChunkedInputSource.h
- Guard S3 includes in XMLFile.cpp and IndexedMzMLDecoder.cpp

Memory safety fixes:
- Fix throw new -> throw (was causing memory corruption)
- Fix memory leaks in makeStream() using std::make_shared
- Fix AWS SDK lifecycle: use shared static initialization via AwsSdkHelper
  to ensure InitAPI/ShutdownAPI called exactly once across all TUs

Error handling improvements:
- parseS3Uri_() now throws on invalid URI instead of silent failure

Code quality:
- Consistent logging: std::cerr -> OPENMS_LOG_ERROR
- Remove redundant GetObject call in S3ChunkedInputSource::makeStream()
- Fix comment typos (GZIP -> bzip2, Bzib2 -> Bzip2)
- Update copyright to 2002-present
- Guard S3 tests with #ifdef WITH_S3

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Jan 15, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7772ec1b-1609-437f-8608-4b7441155f34

📥 Commits

Reviewing files that changed from the base of the PR and between f59ba4f and 28d827f.

📒 Files selected for processing (2)
  • CMakeLists.txt
  • cmake/cmake_findExternalLibs.cmake
🚧 Files skipped from review as they are similar to previous changes (2)
  • CMakeLists.txt
  • cmake/cmake_findExternalLibs.cmake

📝 Walkthrough

Walkthrough

Add AWS S3 support to OpenMS for streaming mzML files from S3 buckets. Introduces new S3 input source classes with both standard and chunked variants, AWS SDK integration, and updates file loading infrastructure to recognize and handle s3:// URIs with optional gzip and bzip2 decompression.

Changes

S3 and Build Configuration

Layer / File(s) Summary
S3 Option and AWS SDK Detection
CMakeLists.txt, cmake/cmake_findExternalLibs.cmake, src/openms/CMakeLists.txt
Added public CMake option WITH_S3 (default OFF). Conditional find_package(AWSSDK REQUIRED COMPONENTS s3) when WITH_S3 enabled. Conditional linking of AWSSDK_LINK_LIBRARIES to OPENMS_DEP_PRIVATE_LIBRARIES.
Build Type Default Handling Removal
CMakeLists.txt
Removed automatic CMAKE_BUILD_TYPE assignment to Release for non-multi-config generators when unset. Removed forced cache assignment of CMAKE_BUILD_TYPE.

Suggested reviewers

  • jpfeuffer

Poem

🐰 Hops through clouds with AWS delight,
S3 chunks streaming left and right,
Gzip, bzip2, uncompressed too—
mzML files, now remote and new!
Network paths hop, metadata glows, ☁️📦

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 5.00% 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 clearly and concisely describes the main feature being added: support for loading XML files from remote locations via S3, HTTP, and FTP protocols.
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.

Implements the TODO from PR OpenMS#8671 to support Indexed MzML for S3.

Changes:
- Add S3 helper functions (parseS3Uri, getS3ObjectSize, readS3Range)
  in anonymous namespace, guarded by WITH_S3
- Update findIndexListOffset() to read last N bytes from S3 using
  range requests
- Update parseOffsets() to read from index offset to EOF from S3
- Remove old commented-out S3 code that was incomplete

The implementation uses HTTP Range requests to efficiently read only
the required portions of the file, avoiding downloading the entire
file for index parsing.

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

@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: 17

🤖 Fix all issues with AI agents
In `@src/openms/CMakeLists.txt`:
- Around line 88-91: The CMakeLists block is appending the literal string
"PRIVATE" into OPENMS_DEP_PRIVATE_LIBRARIES; inside the WITH_S3 conditional
remove the erroneous PRIVATE token and append only the AWSSDK_LINK_LIBRARIES
variable (i.e. update the list(APPEND OPENMS_DEP_PRIVATE_LIBRARIES ...) call so
it adds ${AWSSDK_LINK_LIBRARIES} without the PRIVATE keyword), since linkage
visibility is already handled elsewhere (see OPENMS_DEP_PRIVATE_LIBRARIES,
AWSSDK_LINK_LIBRARIES, and WITH_S3).

In `@src/openms/include/OpenMS/FORMAT/DATAACCESS/S3ChunkedInputSource.h`:
- Around line 24-38: The public class S3ChunkedInputSource (and any other public
non-template classes in this header) must be exported for shared builds: add the
OPENMS_DLLAPI macro to the class declaration (e.g., change "class
S3ChunkedInputSource" to "class OPENMS_DLLAPI S3ChunkedInputSource") so the
class and its public methods (constructor S3ChunkedInputSource, makeStream,
etc.) are exported on Windows; apply the same change to other public classes in
the file (lines ~40-119) to comply with OpenMS DLL export guidelines.
- Around line 42-62: The members and parameters using unsigned long in
S3ChunkedBinInputStream (constructor parameter chunkSize, and members
m_chunkSize, m_currentChunkEnd, m_totalSize) can overflow on 32-bit platforms;
change their types to OpenMS::Size (or UInt64) throughout the class and any
related methods (constructor, readBytes, curPos, and any range handling that
updates m_req) so chunk arithmetic and offset math use the wider OpenMS size
type consistently; update signatures and any callers/assignments to
convert/validate values accordingly.
- Around line 24-108: The public classes and methods lack Doxygen comments; add
brief Doxygen `@brief` and `@param` (and `@return` where appropriate) tags to
S3ChunkedInputSource (constructor S3ChunkedInputSource and makeStream),
S3ChunkedBinInputStream (constructor, curPos, readBytes, getContentType),
S3ChunkedGzipBinInputStream (constructor, destructor, curPos, readBytes,
getContentType) and S3ChunkedBzip2BinInputStream (constructor, destructor,
curPos, readBytes, getContentType) in the header, placing comments immediately
above each class and public method describing purpose and parameters (e.g.,
`@param` client, `@param` req, `@param` chunkSize) and return values for methods like
readBytes/curPos/getContentType.

In `@src/openms/include/OpenMS/FORMAT/DATAACCESS/S3InputSource.h`:
- Around line 92-108: The methods in S3Bzip2BinInputStream are missing override
specifiers; update the declarations of XMLFilePos curPos(), XMLSize_t
readBytes(XMLByte* const toFill, const XMLSize_t maxToRead), and const XMLCh*
getContentType() in class S3Bzip2BinInputStream to append the override keyword
so they explicitly override xercesc::BinInputStream virtuals; also consider
marking the destructor ~S3Bzip2BinInputStream() as override if the base class
destructor is virtual.
- Around line 41-54: The four exported classes S3InputSource, S3BinInputStream,
S3GzipBinInputStream, and S3Bzip2BinInputStream are missing the OPENMS_DLLAPI
export macro; update each class declaration to insert OPENMS_DLLAPI immediately
after the class keyword (e.g., change "class S3InputSource" to "class
OPENMS_DLLAPI S3InputSource") and ensure the header includes the file that
defines OPENMS_DLLAPI if not already included so the macro is available.

In `@src/openms/include/OpenMS/METADATA/DocumentIdentifier.h`:
- Around line 76-88: Add Doxygen `@brief` and `@param` (and `@return` for getter)
documentation to the new public methods: setLoadedNetFilePath(const String &
file_name), getLoadedFilePath() const, setLoadedFileType(const String &
file_name) and setLoadedFileType(FileTypes::Type type). For each setter add a
short `@brief` describing what is set and a `@param` describing the parameter (e.g.
file_name is the absolute or network path / file type string), and for
getLoadedFilePath add an `@brief` and an `@return` describing the returned absolute
path string; place these comments immediately above the method declarations
following the project's Doxygen style.
- Around line 83-88: Update the pyOpenMS pxd for DocumentIdentifier to match the
C++ API: add a declaration for setLoadedNetFilePath(String file_name) and add
the overloaded declaration setLoadedFileType(FileTypes::Type type) in
DocumentIdentifier.pxd, and change the declared return type of
getLoadedFileType() from int to FileTypes::Type; ensure you cimport or reference
FileTypes::Type appropriately in the pxd so the type is resolved (match C++
signatures exactly).

In `@src/openms/source/FORMAT/DATAACCESS/S3ChunkedInputSource.cpp`:
- Around line 165-173: The S3 chunk fetch logs errors but leaves
currentBodyStream pointing to a stale/EOF stream causing an infinite loop;
update the GetObject failure path in the block using m_req / m_currentChunkEnd /
m_chunkSize / m_client.GetObject so it stops iteration: on outcome.IsSuccess()
== false, reset currentBodyStream to nullptr (and clear/close m_currentChunk as
needed) and either throw an exception or return/fail from the surrounding read
loop so no further reads are attempted; ensure any callers of the function
handle the thrown error or return code accordingly.
- Around line 129-138: The code assumes m_currentChunk.GetContentRange() always
contains a valid "bytes X-Y/Total" string and directly calls std::stoull into
m_totalSize; fix by validating the ContentRange string before parsing: check for
empty string, ensure slashPos != npos and the substring after slash is
non-empty, then parse inside a try/catch to handle
std::invalid_argument/std::out_of_range; on any failure fall back to using
m_currentChunk.GetContentLength() (or set m_totalSize = 0) and emit a clear
OPENMS_LOG_ERROR mentioning GetContentRange() parsing failed and that
ContentLength fallback was used so m_totalSize is always initialized.
- Around line 228-328: The Gzip variant S3ChunkedGzipBinInputStream::readBytes
can hang in its outer while loop when the currentBodyStream enters an error
state or when fetching the next chunk fails; update the branches handling failed
chunk fetch (where outcome.IsSuccess() is false) and the "neither good nor eof"
branch (checking currentBodyStream->rdstate()) to break or return immediately
(e.g., break out of the outer loop or return totalBytesRead) instead of only
logging, so the function doesn't spin forever; specifically modify the failure
path after m_client.GetObject(outcome) and the error-state branch to stop
processing (use break/return) and ensure any needed cleanup or final inflate
draining happens before returning.
- Around line 143-181: S3ChunkedBinInputStream::readBytes can spin forever when
currentBodyStream is in an error state that is neither good() nor eof(); after
logging the error (the branch that logs currentBodyStream->rdstate()), either
break out and return the bytes read so far or propagate an error — update that
branch to stop the loop (e.g. return static_cast<XMLSize_t>(totalBytesRead)
after the OPENMS_LOG_ERROR) so totalBytesRead isn't left unchanged and the
method can't loop forever; reference currentBodyStream, totalBytesRead, and the
readBytes method when making this change.
- Around line 117-139: The constructor S3ChunkedBinInputStream currently logs
AWS GetObject failures but continues, leaving m_currentChunk and m_totalSize
invalid; change the constructor to fail fast: after m_client.GetObject(req) if
outcome.IsSuccess() is false, build a descriptive error string from
outcome.GetError().GetExceptionName() and GetMessage() and throw a
std::runtime_error (or another appropriate exception) to abort construction;
similarly, if ContentRange parsing fails (slash not found or std::stoull throws)
throw with a clear message so callers of readBytes cannot operate on a
partially-initialized object.
- Around line 373-472: The read loop in S3ChunkedBzip2BinInputStream::readBytes
can spin forever on decompression and S3 errors because error paths
(BZ2_bzDecompress returning non-BZ_OK and S3 GetObject failures / stream errors)
only log but do not break/return; update the error branches that log via
OPENMS_LOG_ERROR (the branches handling ret != BZ_OK after BZ2_bzDecompress, and
the S3 outcome.IsSuccess() false / stream rdstate() error paths) to exit the
outer read loop immediately (either break out to return totalBytesRead or return
static_cast<XMLSize_t>(totalBytesRead)) so the function stops trying to read
after an unrecoverable error; ensure you reference m_bzStream, BZ2_bzDecompress,
currentBodyStream, m_client.GetObject/outcome, and m_req when applying the
fixes.

In `@src/openms/source/FORMAT/DATAACCESS/S3InputSource.cpp`:
- Around line 111-128: Replace the std::runtime_error throws in
S3InputSource::parseS3Uri_ with OpenMS Exception::Base-derived exceptions (e.g.,
OpenMS::Exception or a more specific subclass) and include
OPENMS_PRETTY_FUNCTION in the exception construction; specifically, when
slashPos == npos throw an OpenMS exception indicating "Invalid S3 URI format:
missing '/' after bucket name" and when m_bucketName or m_objectKey is empty
throw an OpenMS exception indicating "Invalid S3 URI: bucket name or object key
is empty", using the same text context but constructed via the OpenMS exception
class and passing OPENMS_PRETTY_FUNCTION to preserve metadata.

In `@src/openms/source/FORMAT/HANDLERS/IndexedMzMLDecoder.cpp`:
- Around line 77-105: Remove the large commented-out S3 implementation block in
IndexedMzMLDecoder.cpp and replace it with a one-line TODO referencing a created
GitHub issue (e.g., TODO: Support Indexed MzML for S3 - see issue #<n>) so work
is tracked; when re-implementing, use the AwsSdkHelper lifecycle wrapper instead
of Aws::InitAPI/Aws::ShutdownAPI, call the existing parseS3Uri_() helper to
split bucket/key, avoid heap-allocating Aws::S3::Model::GetObjectOutcome (do not
use new/delete), ensure the function returns the correct int value per its
signature, and implement proper resource/stream ownership handling rather than
leaving commented or partial code.
🧹 Nitpick comments (8)
src/openms/source/FORMAT/DATAACCESS/S3ChunkedInputSource.cpp (4)

89-95: Consider removing unused methods.

initializeAwsSdk_() simply delegates to AwsSdkHelper::initializeAwsSdk() and cleanupAwsSdk_() is empty. If these are required by the class interface, consider documenting why; otherwise, they could be removed to reduce dead code.


97-115: Duplicate code with S3InputSource::parseS3Uri_.

This implementation is identical to S3InputSource::parseS3Uri_(). Consider extracting to a shared utility function to avoid duplication.

💡 Suggested refactor

Extract the URI parsing to a shared helper in a common header/source file:

// In a shared utility (e.g., S3Utils.h/cpp)
namespace OpenMS {
  std::pair<std::string, std::string> parseS3Uri(const std::string& s3Uri);
}

228-328: Consider extracting common chunked reading logic to reduce duplication.

The readBytes implementations for Gzip and Bzip2 are nearly identical, differing only in the decompression function calls (inflate vs BZ2_bzDecompress) and error codes. This is a significant amount of duplicated code (~100 lines each). A template or base class approach could reduce maintenance burden.

Also applies to: 373-472


477-477: Extra semicolon after namespace closing brace.

Per coding guidelines, the semicolon after the closing brace of namespace is unnecessary.

💡 Suggested fix
-}; // namespace OpenMS
+} // namespace OpenMS
src/openms/source/FORMAT/MzMLFile.cpp (1)

146-153: Minor formatting: Opening brace should be on its own line.

Per the coding guidelines, opening braces should be placed on their own lines, aligned vertically. The else on line 150 has the opening brace on the same line.

🔧 Suggested fix
     if (filename.hasPrefix("http:") || filename.hasPrefix("https:") || filename.hasPrefix("ftp:") || filename.hasPrefix("s3:"))
     {
       map.setLoadedFileType(FileTypes::MZML);
       map.setLoadedNetFilePath(filename);
-    } else {
+    }
+    else
+    {
       map.setLoadedFileType(filename);
       map.setLoadedFilePath(filename);
     }
src/tests/class_tests/openms/source/MzMLFile_test.cpp (1)

970-990: Consider adding metadata verification and addressing test stability.

The tests verify basic loading functionality but don't verify the DocumentIdentifier metadata that was added in MzMLFile::load:

  1. exp.getLoadedFilePath() should equal the S3 URI
  2. exp.getLoadedFileType() should be FileTypes::MZML

Also, hardcoded S3 bucket URIs (s3://jpmstest/...) may become unavailable over time, potentially causing test flakiness. Consider documenting the bucket ownership or using a more controlled test resource.

🔧 Suggested enhancement
 START_SECTION([EXTRA] load from s3 gzipped)
 {
   MzMLFile file;
   PeakMap exp;
   // Note: Requires AWS credentials and network access to S3 bucket
   file.load("s3://jpmstest/MapAlignmentAlgorithmPoseClustering_in1.mzML.gz", exp);
   TEST_EQUAL(exp.size(), 2035)
+  // Verify DocumentIdentifier metadata for remote files
+  TEST_STRING_EQUAL(exp.getLoadedFilePath(), "s3://jpmstest/MapAlignmentAlgorithmPoseClustering_in1.mzML.gz");
+  TEST_STRING_EQUAL(FileTypes::typeToName(exp.getLoadedFileType()), "mzML");
 }
 END_SECTION
src/openms/source/METADATA/DocumentIdentifier.cpp (1)

52-57: Misleading comment: Qt path handling doesn't apply to network paths.

The comment mentions Qt case alteration, but this method performs a direct assignment without any Qt function calls. The comment appears to be copied from setLoadedFilePath but doesn't apply here.

📝 Suggested fix
   void DocumentIdentifier::setLoadedNetFilePath(const String & file_name)
   {
-    // only change the path if we need to, otherwise low and upper case might be altered by Qt, making comparison in tests more tricky
-    // i.e., a call to this will report unmatched strings
+    // Directly assign network file path (no path resolution needed for remote URIs)
     file_path_ = file_name;
   }
src/openms/include/OpenMS/FORMAT/DATAACCESS/S3InputSource.h (1)

52-53: Consider using trailing underscore for private member variables.

Per coding guidelines, private and protected member variables should use a trailing underscore (e.g., bucket_name_ instead of m_bucketName). The current m_ prefix style is common but doesn't match the OpenMS convention.

This is a minor inconsistency and may be acceptable if following AWS SDK naming patterns was intentional.

Also applies to: 67-69, 85-89, 103-107

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 86c8218 and f59ba4f.

📒 Files selected for processing (16)
  • CMakeLists.txt
  • cmake/cmake_findExternalLibs.cmake
  • src/openms/CMakeLists.txt
  • src/openms/include/OpenMS/FORMAT/DATAACCESS/S3ChunkedInputSource.h
  • src/openms/include/OpenMS/FORMAT/DATAACCESS/S3InputSource.h
  • src/openms/include/OpenMS/FORMAT/DATAACCESS/sources.cmake
  • src/openms/include/OpenMS/METADATA/DocumentIdentifier.h
  • src/openms/source/FORMAT/DATAACCESS/S3ChunkedInputSource.cpp
  • src/openms/source/FORMAT/DATAACCESS/S3InputSource.cpp
  • src/openms/source/FORMAT/DATAACCESS/sources.cmake
  • src/openms/source/FORMAT/HANDLERS/IndexedMzMLDecoder.cpp
  • src/openms/source/FORMAT/HANDLERS/XMLHandler.cpp
  • src/openms/source/FORMAT/MzMLFile.cpp
  • src/openms/source/FORMAT/XMLFile.cpp
  • src/openms/source/METADATA/DocumentIdentifier.cpp
  • src/tests/class_tests/openms/source/MzMLFile_test.cpp
🧰 Additional context used
📓 Path-based instructions (13)
**

📄 CodeRabbit inference engine (AGENTS.md)

**: Do not commit secrets, credentials, or .env files to the repository
Never build the project unless explicitly asked, as it is extremely resource-intensive
Do not modify the contrib tree or third-party dependencies without explicit approval from the maintainers
Always run and extend tests when making code changes; do not skip tests
Follow Gitflow workflow: develop features on forks, open PRs against develop branch, use commit message format [TAG1,TAG2] summary with tags like NOP, DOC, COMMENT, API, INTERNAL, FEATURE, FIX, TEST, FORMAT, PARAM, IO, LOG, GUI, RESOURCE, BUILD
Update AUTHORS and CHANGELOG files when making significant contributions; add Fixes #N or `Closes `#N to commit messages for issue tracking
When changing C++ APIs, update corresponding .pxd files and pyOpenMS addons; when adding TOPP tools, register in src/topp/executables.cmake and ToolHandler.cpp; when changing file formats, update FileHandler::NamesOfTypes[] and schemas

Files:

  • src/openms/source/FORMAT/DATAACCESS/sources.cmake
  • CMakeLists.txt
  • src/openms/include/OpenMS/METADATA/DocumentIdentifier.h
  • src/openms/include/OpenMS/FORMAT/DATAACCESS/sources.cmake
  • src/openms/source/FORMAT/HANDLERS/IndexedMzMLDecoder.cpp
  • src/openms/source/FORMAT/HANDLERS/XMLHandler.cpp
  • src/openms/source/FORMAT/XMLFile.cpp
  • src/tests/class_tests/openms/source/MzMLFile_test.cpp
  • src/openms/source/FORMAT/MzMLFile.cpp
  • src/openms/CMakeLists.txt
  • cmake/cmake_findExternalLibs.cmake
  • src/openms/source/METADATA/DocumentIdentifier.cpp
  • src/openms/source/FORMAT/DATAACCESS/S3ChunkedInputSource.cpp
  • src/openms/source/FORMAT/DATAACCESS/S3InputSource.cpp
  • src/openms/include/OpenMS/FORMAT/DATAACCESS/S3InputSource.h
  • src/openms/include/OpenMS/FORMAT/DATAACCESS/S3ChunkedInputSource.h
**/CMakeLists.txt

📄 CodeRabbit inference engine (CLAUDE.md)

**/CMakeLists.txt: Use -DBOOST_USE_STATIC_LIBS=OFF when configuring CMake to avoid Boost linker errors on macOS due to incomplete transitive dependency declarations
Use semicolons (;) as list separators in CMAKE_PREFIX_PATH when using the -D CMake option

Files:

  • CMakeLists.txt
  • src/openms/CMakeLists.txt
CMakeLists.txt

📄 CodeRabbit inference engine (AGENTS.md)

CMakeLists.txt: Use CMake 3.21+ minimum version; enable out-of-tree builds in OpenMS-build/ directory; use CMAKE_BUILD_TYPE=Debug for development to preserve assertions and conditions
Set OPENMS_CONTRIB_LIBS and CMAKE_PREFIX_PATH for dependency resolution; use semicolons as list separators in -D options (OS-native separators in environment variables)

Files:

  • CMakeLists.txt
src/openms/**/*.{cpp,h,hpp,cc,cxx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

src/openms/**/*.{cpp,h,hpp,cc,cxx}: Follow the existing C++ coding conventions in the codebase
Use the established naming patterns for classes, methods, and variables
Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)
Follow the established error handling patterns
Utilize OpenMS logging mechanisms
Be mindful of memory usage when processing large datasets
Consider algorithmic complexity for data processing operations
Use appropriate OpenMS containers and algorithms

Files:

  • src/openms/include/OpenMS/METADATA/DocumentIdentifier.h
  • src/openms/source/FORMAT/HANDLERS/IndexedMzMLDecoder.cpp
  • src/openms/source/FORMAT/HANDLERS/XMLHandler.cpp
  • src/openms/source/FORMAT/XMLFile.cpp
  • src/openms/source/FORMAT/MzMLFile.cpp
  • src/openms/source/METADATA/DocumentIdentifier.cpp
  • src/openms/source/FORMAT/DATAACCESS/S3ChunkedInputSource.cpp
  • src/openms/source/FORMAT/DATAACCESS/S3InputSource.cpp
  • src/openms/include/OpenMS/FORMAT/DATAACCESS/S3InputSource.h
  • src/openms/include/OpenMS/FORMAT/DATAACCESS/S3ChunkedInputSource.h
src/openms/include/OpenMS/**/*.h

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Add Doxygen comments for new public methods and classes

Files:

  • src/openms/include/OpenMS/METADATA/DocumentIdentifier.h
  • src/openms/include/OpenMS/FORMAT/DATAACCESS/S3InputSource.h
  • src/openms/include/OpenMS/FORMAT/DATAACCESS/S3ChunkedInputSource.h
**/*.{h,hpp}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{h,hpp}: Never add using namespace or using std::... declarations in header files
Add OPENMS_DLLAPI macro to all non-template exported classes, structs, functions, and variables in headers
Include only base class headers, non-pointer members, and template definitions in header files; use forward declarations for other types
Use Doxygen documentation with @brief tag (required), followed by blank line and details; use @param[in], @param[out], or @param[in,out] for all parameters
Include file header preamble with copyright, SPDX license, $Maintainer:$ marker, and $Authors:$ marker in every header file
Use _impl.h files only when necessary for template implementations; .h files must never include _impl.h files directly

Files:

  • src/openms/include/OpenMS/METADATA/DocumentIdentifier.h
  • src/openms/include/OpenMS/FORMAT/DATAACCESS/S3InputSource.h
  • src/openms/include/OpenMS/FORMAT/DATAACCESS/S3ChunkedInputSource.h
**/*.{cpp,h,hpp}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{cpp,h,hpp}: Use 2-space indentation for C++ files (no tabs); use Unix line endings (LF)
Place opening and closing braces on their own lines, aligned vertically; always use braces even for single-line blocks (trivial one-liners may stay single-line)
Add space after keywords (if, for, while, switch) and around binary operators
Use PascalCase for class names, type names, and namespace names; use lowerCamelCase for method names; use snake_case for variable names; use trailing underscore for private and protected member variables
Use UPPER_SNAKE_CASE for enum constants and macro names; prefer enum class over unscoped enums and avoid preprocessor macros when possible
One class per file; pair each .h header file with a corresponding .cpp implementation file; class name must match file name
Use OpenMS primitive types from OpenMS/CONCEPT/Types.h (e.g., Size, SignedSize) instead of standard types like int, unsigned int for STL container sizes
Avoid std::endl; prefer \n for better performance in logging and output operations
Avoid raw pointers; prefer references for parameters and member variables
Use Rule-of-0 (if no explicit destructors/copy operations needed) or Rule-of-6 (if custom copy/move needed) for class definitions
Provide get/set accessor pairs for protected and private member variables; do not return references to primitive types from getters
Derive custom exceptions from Exception::Base; throw exceptions with file, line number, and function name using OPENMS_PRETTY_FUNCTION; catch exceptions by reference
Use OpenMS logging macros and OpenMS::LogStream instead of std::cout and std::cerr directly

Files:

  • src/openms/include/OpenMS/METADATA/DocumentIdentifier.h
  • src/openms/source/FORMAT/HANDLERS/IndexedMzMLDecoder.cpp
  • src/openms/source/FORMAT/HANDLERS/XMLHandler.cpp
  • src/openms/source/FORMAT/XMLFile.cpp
  • src/tests/class_tests/openms/source/MzMLFile_test.cpp
  • src/openms/source/FORMAT/MzMLFile.cpp
  • src/openms/source/METADATA/DocumentIdentifier.cpp
  • src/openms/source/FORMAT/DATAACCESS/S3ChunkedInputSource.cpp
  • src/openms/source/FORMAT/DATAACCESS/S3InputSource.cpp
  • src/openms/include/OpenMS/FORMAT/DATAACCESS/S3InputSource.h
  • src/openms/include/OpenMS/FORMAT/DATAACCESS/S3ChunkedInputSource.h
**/*.{cpp,h,hpp,pyx,pxd}

📄 CodeRabbit inference engine (AGENTS.md)

Add comments in plain English describing the next few lines; maintain at least ~5% of code as comments

Files:

  • src/openms/include/OpenMS/METADATA/DocumentIdentifier.h
  • src/openms/source/FORMAT/HANDLERS/IndexedMzMLDecoder.cpp
  • src/openms/source/FORMAT/HANDLERS/XMLHandler.cpp
  • src/openms/source/FORMAT/XMLFile.cpp
  • src/tests/class_tests/openms/source/MzMLFile_test.cpp
  • src/openms/source/FORMAT/MzMLFile.cpp
  • src/openms/source/METADATA/DocumentIdentifier.cpp
  • src/openms/source/FORMAT/DATAACCESS/S3ChunkedInputSource.cpp
  • src/openms/source/FORMAT/DATAACCESS/S3InputSource.cpp
  • src/openms/include/OpenMS/FORMAT/DATAACCESS/S3InputSource.h
  • src/openms/include/OpenMS/FORMAT/DATAACCESS/S3ChunkedInputSource.h
**/*.{h,hpp,cpp}

📄 CodeRabbit inference engine (AGENTS.md)

Prefer OpenMS::String for numeric formatting and parsing due to precision and performance advantages

Files:

  • src/openms/include/OpenMS/METADATA/DocumentIdentifier.h
  • src/openms/source/FORMAT/HANDLERS/IndexedMzMLDecoder.cpp
  • src/openms/source/FORMAT/HANDLERS/XMLHandler.cpp
  • src/openms/source/FORMAT/XMLFile.cpp
  • src/tests/class_tests/openms/source/MzMLFile_test.cpp
  • src/openms/source/FORMAT/MzMLFile.cpp
  • src/openms/source/METADATA/DocumentIdentifier.cpp
  • src/openms/source/FORMAT/DATAACCESS/S3ChunkedInputSource.cpp
  • src/openms/source/FORMAT/DATAACCESS/S3InputSource.cpp
  • src/openms/include/OpenMS/FORMAT/DATAACCESS/S3InputSource.h
  • src/openms/include/OpenMS/FORMAT/DATAACCESS/S3ChunkedInputSource.h
**/*.cpp

📄 CodeRabbit inference engine (AGENTS.md)

Use ProgressLogger in command-line tools for progress reporting to users

Files:

  • src/openms/source/FORMAT/HANDLERS/IndexedMzMLDecoder.cpp
  • src/openms/source/FORMAT/HANDLERS/XMLHandler.cpp
  • src/openms/source/FORMAT/XMLFile.cpp
  • src/tests/class_tests/openms/source/MzMLFile_test.cpp
  • src/openms/source/FORMAT/MzMLFile.cpp
  • src/openms/source/METADATA/DocumentIdentifier.cpp
  • src/openms/source/FORMAT/DATAACCESS/S3ChunkedInputSource.cpp
  • src/openms/source/FORMAT/DATAACCESS/S3InputSource.cpp
src/tests/class_tests/openms/**/*.cpp

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Write unit tests for new functionality

Files:

  • src/tests/class_tests/openms/source/MzMLFile_test.cpp
src/tests/class_tests/**/source/*_test.cpp

📄 CodeRabbit inference engine (AGENTS.md)

src/tests/class_tests/**/source/*_test.cpp: Use START_TEST(ClassName, "$Id$") and START_SECTION(description) macros; wrap template methods with 2+ arguments in parentheses within START_SECTION
Use NEW_TMP_FILE(filename) for each temporary output file in tests to avoid side effects; do not reuse output files across test sections
Use FuzzyDiff for numeric comparisons in tests; keep test data small; use whitelist for unstable lines

Files:

  • src/tests/class_tests/openms/source/MzMLFile_test.cpp
src/tests/class_tests/openms/source/*_test.cpp

📄 CodeRabbit inference engine (AGENTS.md)

Place test data files in src/tests/class_tests/libs/data/ directory and prefix them with the class name

Files:

  • src/tests/class_tests/openms/source/MzMLFile_test.cpp
🧠 Learnings (27)
📚 Learning: 2026-01-15T17:33:37.739Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T17:33:37.739Z
Learning: Applies to CMakeLists.txt : Set `OPENMS_CONTRIB_LIBS` and `CMAKE_PREFIX_PATH` for dependency resolution; use semicolons as list separators in `-D` options (OS-native separators in environment variables)

Applied to files:

  • src/openms/source/FORMAT/DATAACCESS/sources.cmake
  • CMakeLists.txt
  • src/openms/include/OpenMS/FORMAT/DATAACCESS/sources.cmake
  • src/openms/CMakeLists.txt
  • cmake/cmake_findExternalLibs.cmake
📚 Learning: 2026-01-15T17:33:37.739Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T17:33:37.739Z
Learning: Applies to ** : When changing C++ APIs, update corresponding `.pxd` files and pyOpenMS addons; when adding TOPP tools, register in `src/topp/executables.cmake` and `ToolHandler.cpp`; when changing file formats, update `FileHandler::NamesOfTypes[]` and schemas

Applied to files:

  • src/openms/source/FORMAT/DATAACCESS/sources.cmake
  • src/openms/include/OpenMS/FORMAT/DATAACCESS/sources.cmake
📚 Learning: 2026-01-15T17:33:37.739Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T17:33:37.739Z
Learning: Applies to src/tests/class_tests/openms/source/*_test.cpp : Place test data files in `src/tests/class_tests/libs/data/` directory and prefix them with the class name

Applied to files:

  • src/openms/source/FORMAT/DATAACCESS/sources.cmake
  • src/openms/include/OpenMS/FORMAT/DATAACCESS/sources.cmake
  • src/openms/source/FORMAT/XMLFile.cpp
  • src/tests/class_tests/openms/source/MzMLFile_test.cpp
  • src/openms/source/FORMAT/DATAACCESS/S3InputSource.cpp
📚 Learning: 2026-01-15T17:33:37.739Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T17:33:37.739Z
Learning: Applies to CMakeLists.txt : Use CMake 3.21+ minimum version; enable out-of-tree builds in `OpenMS-build/` directory; use `CMAKE_BUILD_TYPE=Debug` for development to preserve assertions and conditions

Applied to files:

  • CMakeLists.txt
  • src/openms/include/OpenMS/FORMAT/DATAACCESS/sources.cmake
  • src/openms/CMakeLists.txt
  • cmake/cmake_findExternalLibs.cmake
📚 Learning: 2026-01-12T12:26:12.890Z
Learnt from: jpfeuffer
Repo: OpenMS/OpenMS PR: 8530
File: src/pyOpenMS/CMakeLists.txt:78-80
Timestamp: 2026-01-12T12:26:12.890Z
Learning: In the OpenMS build system (src/pyOpenMS/CMakeLists.txt and related), when building pyOpenMS in standalone mode (via find_package(OpenMS REQUIRED)), the OpenMSConfig.cmake automatically finds all necessary public dependencies including Qt6, so Qt6_VERSION and related variables are available in both standalone and in-tree builds.

Applied to files:

  • CMakeLists.txt
  • src/openms/CMakeLists.txt
  • cmake/cmake_findExternalLibs.cmake
📚 Learning: 2026-01-15T17:33:37.739Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T17:33:37.739Z
Learning: Applies to src/topp/*.cpp : Register TOPP tool in `src/topp/executables.cmake` and in `src/openms/source/APPLICATIONS/ToolHandler.cpp` to enable help generation

Applied to files:

  • CMakeLists.txt
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Do not attempt to build OpenMS unless asked to do so

Applied to files:

  • CMakeLists.txt
📚 Learning: 2026-01-15T17:33:37.739Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T17:33:37.739Z
Learning: Applies to src/topp/*.cpp : TOPP tool must define parameters in `registerOptionsAndFlags_()` method and read them using `getStringOption_` and related helper methods

Applied to files:

  • CMakeLists.txt
📚 Learning: 2026-01-14T18:51:46.097Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-14T18:51:46.097Z
Learning: Applies to **/CMakeLists.txt : Use `-DBOOST_USE_STATIC_LIBS=OFF` when configuring CMake to avoid Boost linker errors on macOS due to incomplete transitive dependency declarations

Applied to files:

  • CMakeLists.txt
  • src/openms/CMakeLists.txt
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/include/OpenMS/**/*.h : Add Doxygen comments for new public methods and classes

Applied to files:

  • src/openms/include/OpenMS/FORMAT/DATAACCESS/sources.cmake
  • src/openms/CMakeLists.txt
  • src/openms/source/FORMAT/DATAACCESS/S3ChunkedInputSource.cpp
  • src/openms/source/FORMAT/DATAACCESS/S3InputSource.cpp
  • src/openms/include/OpenMS/FORMAT/DATAACCESS/S3ChunkedInputSource.h
📚 Learning: 2026-01-15T17:33:37.739Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T17:33:37.739Z
Learning: Applies to src/openms/extern/** : Never modify files in `src/openms/extern/` as they are third-party vendored code

Applied to files:

  • src/openms/include/OpenMS/FORMAT/DATAACCESS/sources.cmake
  • src/openms/CMakeLists.txt
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Be mindful of memory usage when processing large datasets

Applied to files:

  • src/openms/source/FORMAT/HANDLERS/IndexedMzMLDecoder.cpp
  • src/openms/source/FORMAT/XMLFile.cpp
  • src/tests/class_tests/openms/source/MzMLFile_test.cpp
  • src/openms/source/FORMAT/DATAACCESS/S3ChunkedInputSource.cpp
  • src/openms/include/OpenMS/FORMAT/DATAACCESS/S3InputSource.h
  • src/openms/include/OpenMS/FORMAT/DATAACCESS/S3ChunkedInputSource.h
📚 Learning: 2025-08-14T10:19:54.371Z
Learnt from: jpfeuffer
Repo: OpenMS/OpenMS PR: 8167
File: src/topp/Digestor.cpp:200-226
Timestamp: 2025-08-14T10:19:54.371Z
Learning: In OpenMS (C++ bioinformatics framework), use boost random libraries instead of std library random distributions for cross-platform reproducible random number generation, as std library distributions are not reproducible across platforms.

Applied to files:

  • src/openms/source/FORMAT/HANDLERS/IndexedMzMLDecoder.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)

Applied to files:

  • src/openms/source/FORMAT/HANDLERS/IndexedMzMLDecoder.cpp
  • src/openms/source/FORMAT/XMLFile.cpp
  • src/tests/class_tests/openms/source/MzMLFile_test.cpp
  • src/openms/source/FORMAT/DATAACCESS/S3ChunkedInputSource.cpp
  • src/openms/source/FORMAT/DATAACCESS/S3InputSource.cpp
  • src/openms/include/OpenMS/FORMAT/DATAACCESS/S3InputSource.h
  • src/openms/include/OpenMS/FORMAT/DATAACCESS/S3ChunkedInputSource.h
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Use appropriate OpenMS containers and algorithms

Applied to files:

  • src/openms/source/FORMAT/HANDLERS/IndexedMzMLDecoder.cpp
  • src/openms/source/FORMAT/XMLFile.cpp
  • src/openms/include/OpenMS/FORMAT/DATAACCESS/S3ChunkedInputSource.h
📚 Learning: 2026-01-15T17:33:37.739Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T17:33:37.739Z
Learning: Applies to **/*.{cpp} : Use `using namespace OpenMS;` and `using std::...;` declarations are allowed in implementation files

Applied to files:

  • src/openms/source/FORMAT/HANDLERS/IndexedMzMLDecoder.cpp
  • src/openms/source/FORMAT/XMLFile.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Utilize OpenMS logging mechanisms

Applied to files:

  • src/openms/source/FORMAT/HANDLERS/IndexedMzMLDecoder.cpp
  • src/openms/source/FORMAT/XMLFile.cpp
📚 Learning: 2026-01-15T17:33:37.739Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T17:33:37.739Z
Learning: Applies to **/*.{cpp,h,hpp} : Derive custom exceptions from `Exception::Base`; throw exceptions with file, line number, and function name using `OPENMS_PRETTY_FUNCTION`; catch exceptions by reference

Applied to files:

  • src/openms/source/FORMAT/HANDLERS/IndexedMzMLDecoder.cpp
  • src/openms/source/FORMAT/XMLFile.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Follow the established error handling patterns

Applied to files:

  • src/openms/source/FORMAT/HANDLERS/IndexedMzMLDecoder.cpp
  • src/openms/source/FORMAT/HANDLERS/XMLHandler.cpp
  • src/openms/source/FORMAT/XMLFile.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/tests/class_tests/openms/**/*.cpp : Write unit tests for new functionality

Applied to files:

  • src/openms/source/FORMAT/HANDLERS/IndexedMzMLDecoder.cpp
  • src/tests/class_tests/openms/source/MzMLFile_test.cpp
  • src/openms/source/FORMAT/DATAACCESS/S3ChunkedInputSource.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Be aware of OpenMS dependencies and external libraries

Applied to files:

  • src/openms/source/FORMAT/HANDLERS/IndexedMzMLDecoder.cpp
  • src/openms/source/FORMAT/XMLFile.cpp
  • src/openms/CMakeLists.txt
  • cmake/cmake_findExternalLibs.cmake
📚 Learning: 2025-10-15T07:49:09.293Z
Learnt from: timosachsenberg
Repo: OpenMS/OpenMS PR: 8177
File: src/openms/include/OpenMS/PROCESSING/CENTROIDING/PeakPickerIM.h:11-14
Timestamp: 2025-10-15T07:49:09.293Z
Learning: In OpenMS, DefaultParamHandler.h is located under OpenMS/DATASTRUCTURES/, not OpenMS/CONCEPT/. The correct include is: `#include <OpenMS/DATASTRUCTURES/DefaultParamHandler.h>`

Applied to files:

  • src/openms/source/FORMAT/XMLFile.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/tests/class_tests/openms/*Test.cpp : Follow naming convention: `ClassNameTest.cpp` for `ClassName`

Applied to files:

  • src/tests/class_tests/openms/source/MzMLFile_test.cpp
📚 Learning: 2026-01-15T17:33:37.739Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T17:33:37.739Z
Learning: Applies to src/tests/class_tests/**/source/*_test.cpp : Use `NEW_TMP_FILE(filename)` for each temporary output file in tests to avoid side effects; do not reuse output files across test sections

Applied to files:

  • src/tests/class_tests/openms/source/MzMLFile_test.cpp
📚 Learning: 2026-01-15T17:33:37.739Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T17:33:37.739Z
Learning: Applies to src/tests/class_tests/**/source/*_test.cpp : Use `FuzzyDiff` for numeric comparisons in tests; keep test data small; use whitelist for unstable lines

Applied to files:

  • src/tests/class_tests/openms/source/MzMLFile_test.cpp
📚 Learning: 2025-09-03T12:58:20.032Z
Learnt from: timosachsenberg
Repo: OpenMS/OpenMS PR: 8177
File: src/tests/topp/CMakeLists.txt:1857-1865
Timestamp: 2025-09-03T12:58:20.032Z
Learning: OpenMS tests: When adding new TOPP tests in src/tests/topp/CMakeLists.txt that compare outputs via FuzzyDiff, always add set_tests_properties("<tool>_<n>_out<m>" PROPERTIES DEPENDS "<tool>_<n>") to avoid flakiness under parallel CTest runs.

Applied to files:

  • src/tests/class_tests/openms/source/MzMLFile_test.cpp
📚 Learning: 2026-01-15T17:33:37.739Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T17:33:37.739Z
Learning: Applies to src/tests/class_tests/**/source/*_test.cpp : Use `START_TEST(ClassName, "$Id$")` and `START_SECTION(description)` macros; wrap template methods with 2+ arguments in parentheses within START_SECTION

Applied to files:

  • src/tests/class_tests/openms/source/MzMLFile_test.cpp
🧬 Code graph analysis (4)
src/openms/include/OpenMS/METADATA/DocumentIdentifier.h (1)
src/openms/source/METADATA/DocumentIdentifier.cpp (8)
  • setLoadedNetFilePath (52-57)
  • setLoadedNetFilePath (52-52)
  • getLoadedFilePath (59-62)
  • getLoadedFilePath (59-59)
  • setLoadedFileType (64-67)
  • setLoadedFileType (64-64)
  • setLoadedFileType (69-72)
  • setLoadedFileType (69-69)
src/tests/class_tests/openms/source/MzMLFile_test.cpp (1)
src/openms/source/FORMAT/MzMLFile.cpp (2)
  • load (141-159)
  • load (141-141)
src/openms/source/FORMAT/DATAACCESS/S3ChunkedInputSource.cpp (3)
src/openms/include/OpenMS/FORMAT/DATAACCESS/S3ChunkedInputSource.h (3)
  • S3ChunkedInputSource (25-38)
  • curPos (48-120)
  • curPos (75-119)
src/openms/include/OpenMS/FORMAT/DATAACCESS/S3InputSource.h (3)
  • initializeAwsSdk (31-38)
  • curPos (60-109)
  • curPos (78-108)
src/openms/source/FORMAT/DATAACCESS/S3InputSource.cpp (27)
  • parseS3Uri_ (111-129)
  • parseS3Uri_ (111-111)
  • makeStream (24-101)
  • makeStream (24-24)
  • s3Client (34-34)
  • initializeAwsSdk_ (103-105)
  • initializeAwsSdk_ (103-103)
  • cleanupAwsSdk_ (107-109)
  • cleanupAwsSdk_ (107-107)
  • curPos (143-143)
  • curPos (143-143)
  • curPos (188-188)
  • curPos (188-188)
  • curPos (243-243)
  • curPos (243-243)
  • readBytes (145-159)
  • readBytes (145-145)
  • readBytes (190-221)
  • readBytes (190-190)
  • readBytes (245-270)
  • readBytes (245-245)
  • getContentType (161-161)
  • getContentType (161-161)
  • getContentType (223-223)
  • getContentType (223-223)
  • getContentType (272-272)
  • getContentType (272-272)
src/openms/source/FORMAT/DATAACCESS/S3InputSource.cpp (3)
src/openms/include/OpenMS/FORMAT/DATAACCESS/S3InputSource.h (4)
  • S3InputSource (41-54)
  • initializeAwsSdk (31-38)
  • curPos (60-109)
  • curPos (78-108)
src/openms/source/FORMAT/DATAACCESS/S3ChunkedInputSource.cpp (26)
  • parseS3Uri_ (97-115)
  • parseS3Uri_ (97-97)
  • makeStream (25-87)
  • makeStream (25-25)
  • initializeAwsSdk_ (89-91)
  • initializeAwsSdk_ (89-89)
  • cleanupAwsSdk_ (93-95)
  • cleanupAwsSdk_ (93-93)
  • curPos (141-141)
  • curPos (141-141)
  • curPos (226-226)
  • curPos (226-226)
  • curPos (371-371)
  • curPos (371-371)
  • readBytes (143-181)
  • readBytes (143-143)
  • readBytes (228-328)
  • readBytes (228-228)
  • readBytes (373-473)
  • readBytes (373-373)
  • getContentType (183-183)
  • getContentType (183-183)
  • getContentType (330-330)
  • getContentType (330-330)
  • getContentType (475-475)
  • getContentType (475-475)
src/openms/include/OpenMS/FORMAT/DATAACCESS/S3ChunkedInputSource.h (2)
  • curPos (48-120)
  • curPos (75-119)
🪛 GitHub Check: CodeFactor
src/openms/source/FORMAT/DATAACCESS/S3ChunkedInputSource.cpp

[notice] 373-474: src/openms/source/FORMAT/DATAACCESS/S3ChunkedInputSource.cpp#L373-L474
Complex Method


[notice] 228-329: src/openms/source/FORMAT/DATAACCESS/S3ChunkedInputSource.cpp#L228-L329
Complex Method

src/openms/source/FORMAT/DATAACCESS/S3InputSource.cpp

[notice] 146-146: src/openms/source/FORMAT/DATAACCESS/S3InputSource.cpp#L146
Redundant blank line at the start of a code block should be deleted. (whitespace/blank_line)


[notice] 24-102: src/openms/source/FORMAT/DATAACCESS/S3InputSource.cpp#L24-L102
Complex Method


[notice] 181-181: src/openms/source/FORMAT/DATAACCESS/S3InputSource.cpp#L181
Redundant blank line at the end of a code block should be deleted. (whitespace/blank_line)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: build-wheels-linux-arm
  • GitHub Check: build-wheels-linux
  • GitHub Check: build-wheels-windows
  • GitHub Check: build-wheels-macos
  • GitHub Check: build-and-test (windows-2025, cl.exe, 14.44)
  • GitHub Check: build-and-test (ubuntu-24.04-arm, g++, 13)
  • GitHub Check: build-and-test (ubuntu-24.04, g++, 13)
  • GitHub Check: build-and-test (ubuntu-24.04, clang++, 17)
🔇 Additional comments (14)
src/openms/source/FORMAT/HANDLERS/IndexedMzMLDecoder.cpp (1)

13-18: LGTM: Properly guarded S3 headers.

The conditional compilation block correctly ensures AWS S3 SDK headers are only included when WITH_S3 is enabled, preventing build errors when the AWS SDK is not available.

src/openms/include/OpenMS/FORMAT/DATAACCESS/sources.cmake (1)

18-23: Conditional S3 header inclusion looks good.

Keeps S3 headers gated by WITH_S3 and avoids pulling them into default builds.

cmake/cmake_findExternalLibs.cmake (1)

164-203: WITH_S3-gated AWS SDK discovery is appropriate.

Clear and scoped to the optional feature.

src/openms/source/FORMAT/DATAACCESS/S3ChunkedInputSource.cpp (4)

19-23: LGTM!

Constructor properly initializes AWS SDK via the shared helper and parses the S3 URI. The initialization flow is correct.


25-87: LGTM - makeStream implementation is well-structured.

The encoding detection logic correctly checks Content-Encoding metadata first, then falls back to magic byte detection. Error handling returns nullptr with appropriate logging. The stream construction delegates initial chunk fetching to the stream constructors.


185-220: Gzip stream constructor has proper error handling - LGTM.

Unlike the base S3ChunkedBinInputStream, this constructor throws on failures, which is the correct behavior. The zlib initialization and chunk fetching are properly validated.


332-365: Bzip2 stream constructor has proper error handling - LGTM.

Consistent with the Gzip variant, proper exception throwing on initialization and chunk fetch failures.

src/openms/source/FORMAT/DATAACCESS/sources.cmake (1)

20-25: LGTM!

The conditional compilation guard correctly appends S3 source files only when WITH_S3 is enabled. This follows the established pattern for optional features in the build system.

src/openms/source/FORMAT/HANDLERS/XMLHandler.cpp (1)

87-99: LGTM - Good defensive check for remote resources.

The extension/content mismatch diagnostic is correctly bypassed for remote URLs (HTTP, HTTPS, FTP, S3) since FileHandler::getTypeByContent() would fail or be meaningless for remote resources. The logic is clear and handles all relevant protocol prefixes.

CMakeLists.txt (1)

55-55: LGTM!

The WITH_S3 option follows the established pattern for optional features (like WITH_HDF5, WITH_PARQUET) with a sensible default of OFF. The AWS SDK is properly integrated via find_package(AWSSDK REQUIRED COMPONENTS s3) in cmake/cmake_findExternalLibs.cmake.

src/openms/source/METADATA/DocumentIdentifier.cpp (1)

69-72: LGTM!

Clean overload that allows direct type assignment, useful for remote files where content-based detection isn't feasible.

src/openms/source/FORMAT/XMLFile.cpp (2)

140-183: LGTM! Well-structured input source selection.

The refactored logic correctly:

  1. Routes HTTP/HTTPS/FTP to URLInputSource
  2. Routes S3 URIs to S3ChunkedInputSource (WITH_S3 guard)
  3. Preserves local file compression detection (gzip/bzip2)

The TODO on lines 147-148 about CompressedURLInputSource is a good reminder for future enhancement.


120-127: LGTM!

Correctly skips the local file readability check for remote URLs. The input sources will handle validation for remote resources.

src/openms/include/OpenMS/FORMAT/DATAACCESS/S3InputSource.h (1)

29-39: Add override keywords to S3Bzip2BinInputStream virtual methods.

Methods curPos() (line 98) and readBytes() (line 99) in the S3Bzip2BinInputStream class are missing the override keyword. This is inconsistent with the parallel S3GzipBinInputStream class and the corresponding chunked implementations, which all use override. Add override to both method declarations for consistency and adherence to modern C++ practices.

⛔ Skipped due to learnings
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Consider algorithmic complexity for data processing operations
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Be mindful of memory usage when processing large datasets

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Comment thread src/openms/CMakeLists.txt
Comment on lines +88 to +91
if (WITH_S3)
## lol.. disgusting cmake.. how would one link to a subset of the AWS SDK?
list(APPEND OPENMS_DEP_PRIVATE_LIBRARIES PRIVATE ${AWSSDK_LINK_LIBRARIES})
endif()

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 | 🔴 Critical

Erroneous PRIVATE keyword inside list(APPEND).

The PRIVATE keyword at line 90 is being appended as a literal string to the list, not as a CMake linkage specifier. This will cause link errors or warnings. The list is already linked as private via PRIVATE_LINK_LIBRARIES at line 122.

🐛 Proposed fix
 if (WITH_S3)
   ## lol.. disgusting cmake.. how would one link to a subset of the AWS SDK?
-  list(APPEND OPENMS_DEP_PRIVATE_LIBRARIES PRIVATE ${AWSSDK_LINK_LIBRARIES})
+  list(APPEND OPENMS_DEP_PRIVATE_LIBRARIES ${AWSSDK_LINK_LIBRARIES})
 endif()
🤖 Prompt for AI Agents
In `@src/openms/CMakeLists.txt` around lines 88 - 91, The CMakeLists block is
appending the literal string "PRIVATE" into OPENMS_DEP_PRIVATE_LIBRARIES; inside
the WITH_S3 conditional remove the erroneous PRIVATE token and append only the
AWSSDK_LINK_LIBRARIES variable (i.e. update the list(APPEND
OPENMS_DEP_PRIVATE_LIBRARIES ...) call so it adds ${AWSSDK_LINK_LIBRARIES}
without the PRIVATE keyword), since linkage visibility is already handled
elsewhere (see OPENMS_DEP_PRIVATE_LIBRARIES, AWSSDK_LINK_LIBRARIES, and
WITH_S3).

Comment on lines +24 to +38
namespace OpenMS {
class S3ChunkedInputSource : public xercesc::InputSource {
public:
S3ChunkedInputSource(const std::string& s3uri);
xercesc::BinInputStream* makeStream() const override;
private:
void initializeAwsSdk_();

void cleanupAwsSdk_();

void parseS3Uri_(std::string s3Uri);

std::string m_bucketName;
std::string m_objectKey;
};

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 | 🟠 Major

Export new public classes with OPENMS_DLLAPI.

These classes are in a public header and should be exported for shared builds (especially on Windows).

🧩 Suggested fix
+#include <OpenMS/CONCEPT/Macros.h>
@@
-    class S3ChunkedInputSource : public xercesc::InputSource {
+    class OPENMS_DLLAPI S3ChunkedInputSource : public xercesc::InputSource {
@@
-    class S3ChunkedBinInputStream : public xercesc::BinInputStream {
+    class OPENMS_DLLAPI S3ChunkedBinInputStream : public xercesc::BinInputStream {
@@
-    class S3ChunkedGzipBinInputStream : public xercesc::BinInputStream {
+    class OPENMS_DLLAPI S3ChunkedGzipBinInputStream : public xercesc::BinInputStream {
@@
-    class S3ChunkedBzip2BinInputStream : public xercesc::BinInputStream {
+    class OPENMS_DLLAPI S3ChunkedBzip2BinInputStream : public xercesc::BinInputStream {

As per coding guidelines, public non-template classes must use OPENMS_DLLAPI.

Also applies to: 40-119

🤖 Prompt for AI Agents
In `@src/openms/include/OpenMS/FORMAT/DATAACCESS/S3ChunkedInputSource.h` around
lines 24 - 38, The public class S3ChunkedInputSource (and any other public
non-template classes in this header) must be exported for shared builds: add the
OPENMS_DLLAPI macro to the class declaration (e.g., change "class
S3ChunkedInputSource" to "class OPENMS_DLLAPI S3ChunkedInputSource") so the
class and its public methods (constructor S3ChunkedInputSource, makeStream,
etc.) are exported on Windows; apply the same change to other public classes in
the file (lines ~40-119) to comply with OpenMS DLL export guidelines.

Comment on lines +24 to +108
namespace OpenMS {
class S3ChunkedInputSource : public xercesc::InputSource {
public:
S3ChunkedInputSource(const std::string& s3uri);
xercesc::BinInputStream* makeStream() const override;
private:
void initializeAwsSdk_();

void cleanupAwsSdk_();

void parseS3Uri_(std::string s3Uri);

std::string m_bucketName;
std::string m_objectKey;
};

class S3ChunkedBinInputStream : public xercesc::BinInputStream {
public:
explicit S3ChunkedBinInputStream(
const Aws::S3::S3Client& client,
const Aws::S3::Model::GetObjectRequest& req,
unsigned long chunkSize = 1024 * 1024 * 100 // 100 MB should be a good default for most cases
);

XMLFilePos curPos() const override;

// Note: Typical maxToRead is 48 KB (48 * 1024)
XMLSize_t readBytes(XMLByte* const toFill, const XMLSize_t maxToRead) override;

const XMLCh* getContentType() const override;

private:
Aws::S3::Model::GetObjectRequest m_req; ///< Copy of the request (bucket + key + range) where the range will be updated
Aws::S3::S3Client m_client; ///< Client to use for the request (with credentials etc.)
XMLFilePos m_position; ///< Current position in the stream important for curPos()
unsigned long m_chunkSize; ///< Size of each chunk to request from S3
unsigned long m_currentChunkEnd; ///< End of the current chunk
unsigned long m_totalSize; ///< Total size of the object to download/stream
Aws::S3::Model::GetObjectResult m_currentChunk; ///< Current chunk of the object as returned by S3
};

class S3ChunkedGzipBinInputStream : public xercesc::BinInputStream {
public:
S3ChunkedGzipBinInputStream(
const Aws::S3::S3Client& client,
const Aws::S3::Model::GetObjectRequest& req,
unsigned long chunkSize = 1024 * 1024 * 100
);

~S3ChunkedGzipBinInputStream();

XMLFilePos curPos() const override;

XMLSize_t readBytes(XMLByte* const toFill, const XMLSize_t maxToRead) override;

const XMLCh* getContentType() const override;

private:
Aws::S3::Model::GetObjectRequest m_req; ///< Copy of the request (bucket + key + range) where the range will be updated
Aws::S3::S3Client m_client; ///< Client to use for the request (with credentials etc.)
XMLFilePos m_position; ///< Current position in the stream important for curPos()
unsigned long m_chunkSize; ///< Size of each chunk to request from S3
unsigned long m_currentChunkEnd; ///< End of the current chunk
unsigned long m_totalSize; ///< Total size of the object to download/stream
Aws::S3::Model::GetObjectResult m_currentChunk; ///< Current chunk of the object as returned by S3
XMLByte m_decompressedBuffer[1024]; ///< Current decompressed buffer
z_stream m_zStream; ///< zlib stream for decompression
};

class S3ChunkedBzip2BinInputStream : public xercesc::BinInputStream {
public:
S3ChunkedBzip2BinInputStream(
const Aws::S3::S3Client& client,
const Aws::S3::Model::GetObjectRequest& req,
unsigned long chunkSize = 1024 * 1024 * 100
);

~S3ChunkedBzip2BinInputStream();

XMLFilePos curPos() const override;

XMLSize_t readBytes(XMLByte* const toFill, const XMLSize_t maxToRead) override;

const XMLCh* getContentType() const override;

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

Add Doxygen docs for the new public classes/methods.

Public interfaces in headers should include @brief and @param tags.

As per coding guidelines, new public API in headers must be documented with Doxygen tags.

🤖 Prompt for AI Agents
In `@src/openms/include/OpenMS/FORMAT/DATAACCESS/S3ChunkedInputSource.h` around
lines 24 - 108, The public classes and methods lack Doxygen comments; add brief
Doxygen `@brief` and `@param` (and `@return` where appropriate) tags to
S3ChunkedInputSource (constructor S3ChunkedInputSource and makeStream),
S3ChunkedBinInputStream (constructor, curPos, readBytes, getContentType),
S3ChunkedGzipBinInputStream (constructor, destructor, curPos, readBytes,
getContentType) and S3ChunkedBzip2BinInputStream (constructor, destructor,
curPos, readBytes, getContentType) in the header, placing comments immediately
above each class and public method describing purpose and parameters (e.g.,
`@param` client, `@param` req, `@param` chunkSize) and return values for methods like
readBytes/curPos/getContentType.

Comment on lines +42 to +62
explicit S3ChunkedBinInputStream(
const Aws::S3::S3Client& client,
const Aws::S3::Model::GetObjectRequest& req,
unsigned long chunkSize = 1024 * 1024 * 100 // 100 MB should be a good default for most cases
);

XMLFilePos curPos() const override;

// Note: Typical maxToRead is 48 KB (48 * 1024)
XMLSize_t readBytes(XMLByte* const toFill, const XMLSize_t maxToRead) override;

const XMLCh* getContentType() const override;

private:
Aws::S3::Model::GetObjectRequest m_req; ///< Copy of the request (bucket + key + range) where the range will be updated
Aws::S3::S3Client m_client; ///< Client to use for the request (with credentials etc.)
XMLFilePos m_position; ///< Current position in the stream important for curPos()
unsigned long m_chunkSize; ///< Size of each chunk to request from S3
unsigned long m_currentChunkEnd; ///< End of the current chunk
unsigned long m_totalSize; ///< Total size of the object to download/stream
Aws::S3::Model::GetObjectResult m_currentChunk; ///< Current chunk of the object as returned by S3

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 | 🟠 Major

Use OpenMS size types to avoid 32‑bit overflows.

unsigned long can be 32‑bit, which risks overflow for large S3 objects. Prefer OpenMS::Size (or UInt64) for chunk sizes and offsets.

🔧 Suggested fix
@@
-        explicit S3ChunkedBinInputStream(
+        explicit S3ChunkedBinInputStream(
             const Aws::S3::S3Client& client,
             const Aws::S3::Model::GetObjectRequest& req,
-            unsigned long chunkSize = 1024 * 1024 * 100 // 100 MB should be a good default for most cases
+            Size chunkSize = 1024UL * 1024 * 100 // 100 MB should be a good default for most cases
         );
@@
-        unsigned long m_chunkSize; ///< Size of each chunk to request from S3
-        unsigned long m_currentChunkEnd; ///< End of the current chunk
-        unsigned long m_totalSize; ///< Total size of the object to download/stream
+        Size m_chunkSize; ///< Size of each chunk to request from S3
+        Size m_currentChunkEnd; ///< End of the current chunk
+        Size m_totalSize; ///< Total size of the object to download/stream
@@
-        S3ChunkedGzipBinInputStream(
+        S3ChunkedGzipBinInputStream(
             const Aws::S3::S3Client& client,
             const Aws::S3::Model::GetObjectRequest& req,
-            unsigned long chunkSize = 1024 * 1024 * 100
+            Size chunkSize = 1024UL * 1024 * 100
         );
@@
-        unsigned long m_chunkSize; ///< Size of each chunk to request from S3
-        unsigned long m_currentChunkEnd; ///< End of the current chunk
-        unsigned long m_totalSize; ///< Total size of the object to download/stream
+        Size m_chunkSize; ///< Size of each chunk to request from S3
+        Size m_currentChunkEnd; ///< End of the current chunk
+        Size m_totalSize; ///< Total size of the object to download/stream
@@
-        S3ChunkedBzip2BinInputStream(
+        S3ChunkedBzip2BinInputStream(
             const Aws::S3::S3Client& client,
             const Aws::S3::Model::GetObjectRequest& req,
-            unsigned long chunkSize = 1024 * 1024 * 100
+            Size chunkSize = 1024UL * 1024 * 100
         );
@@
-        unsigned long m_chunkSize; ///< Size of each chunk to request from S3
-        unsigned long m_currentChunkEnd; ///< End of the current chunk
-        unsigned long m_totalSize; ///< Total size of the object to download/stream
+        Size m_chunkSize; ///< Size of each chunk to request from S3
+        Size m_currentChunkEnd; ///< End of the current chunk
+        Size m_totalSize; ///< Total size of the object to download/stream

As per coding guidelines, prefer OpenMS size types for sizes/offsets to avoid overflow.

Also applies to: 82-118

🤖 Prompt for AI Agents
In `@src/openms/include/OpenMS/FORMAT/DATAACCESS/S3ChunkedInputSource.h` around
lines 42 - 62, The members and parameters using unsigned long in
S3ChunkedBinInputStream (constructor parameter chunkSize, and members
m_chunkSize, m_currentChunkEnd, m_totalSize) can overflow on 32-bit platforms;
change their types to OpenMS::Size (or UInt64) throughout the class and any
related methods (constructor, readBytes, curPos, and any range handling that
updates m_req) so chunk arithmetic and offset math use the wider OpenMS size
type consistently; update signatures and any callers/assignments to
convert/validate values accordingly.

Comment on lines +41 to +54
class S3InputSource : public xercesc::InputSource {
public:
S3InputSource(const std::string& s3uri);
xercesc::BinInputStream* makeStream() const override;
private:
void initializeAwsSdk_();

void cleanupAwsSdk_();

void parseS3Uri_(std::string s3Uri);

std::string m_bucketName;
std::string m_objectKey;
};

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check how other input source classes handle OPENMS_DLLAPI
rg -n "class.*InputSource" src/openms/include --type h -A 1 | head -50

Repository: OpenMS/OpenMS

Length of output: 860


🏁 Script executed:

#!/bin/bash
# Check the content of the S3InputSource.h file to understand its structure
cat -n src/openms/include/OpenMS/FORMAT/DATAACCESS/S3InputSource.h

Repository: OpenMS/OpenMS

Length of output: 4321


🏁 Script executed:

#!/bin/bash
# Search for OPENMS_DLLAPI usage in related files
rg "OPENMS_DLLAPI" src/openms/include/OpenMS/FORMAT/DATAACCESS --type h

Repository: OpenMS/OpenMS

Length of output: 1787


🏁 Script executed:

#!/bin/bash
# Check if S3InputSource is used outside its file (cross-DLL boundary usage)
rg "S3InputSource" src/openms --type h --type cpp | head -20

Repository: OpenMS/OpenMS

Length of output: 1165


Add OPENMS_DLLAPI macro to exported classes.

The classes S3InputSource, S3BinInputStream, S3GzipBinInputStream, and S3Bzip2BinInputStream are missing the OPENMS_DLLAPI macro required by coding guidelines for exported classes. Similar classes like CompressedInputSource and all other classes in the DATAACCESS directory include this macro. Add OPENMS_DLLAPI after class keyword for each of these four classes.

🤖 Prompt for AI Agents
In `@src/openms/include/OpenMS/FORMAT/DATAACCESS/S3InputSource.h` around lines 41
- 54, The four exported classes S3InputSource, S3BinInputStream,
S3GzipBinInputStream, and S3Bzip2BinInputStream are missing the OPENMS_DLLAPI
export macro; update each class declaration to insert OPENMS_DLLAPI immediately
after the class keyword (e.g., change "class S3InputSource" to "class
OPENMS_DLLAPI S3InputSource") and ensure the header includes the file that
defines OPENMS_DLLAPI if not already included so the macro is available.

Comment on lines +228 to +328
XMLSize_t S3ChunkedGzipBinInputStream::readBytes(XMLByte* const toFill, const XMLSize_t maxToRead) {
auto currentBodyStream = &m_currentChunk.GetBody();
unsigned long totalBytesRead = 0;
// while maxToRead is not reached
while (totalBytesRead < maxToRead) {
unsigned long remainingBytes = maxToRead - totalBytesRead;
// read from current chunk
if (currentBodyStream->good())
{
do {
m_zStream.avail_out = remainingBytes;
m_zStream.next_out = reinterpret_cast<Bytef*>(toFill + totalBytesRead);

if (m_zStream.avail_in == 0)
{ // no bytes from last call in the zlib buffer anymore.
// Read more from current chunk if available
if (currentBodyStream->good()) {
currentBodyStream->read(reinterpret_cast<char*>(m_decompressedBuffer), 1024);
m_zStream.avail_in = currentBodyStream->gcount();
m_zStream.next_in = reinterpret_cast<Bytef*>(m_decompressedBuffer);
}
else {
// Handle error or end of stream
break;
}
}

int ret = inflate(&m_zStream, Z_NO_FLUSH);
if (ret == Z_STREAM_END) {
// Reached end of compressed data
unsigned long bytesRead = remainingBytes - m_zStream.avail_out;
totalBytesRead += bytesRead;
m_position += bytesRead;
remainingBytes = m_zStream.avail_out;
break;
}
else if (ret != Z_OK) {
OPENMS_LOG_ERROR << "Error occurred during decompression. Zlib error code: " << ret << std::endl;
break;
}

unsigned long bytesRead = remainingBytes - m_zStream.avail_out;
totalBytesRead += bytesRead;
m_position += bytesRead;
remainingBytes = m_zStream.avail_out; // Update remainingBytes after each call to inflate
} while (remainingBytes > 0); // Continue the loop while there is still space in toFill
}
else if (currentBodyStream->eof())
{
// if the end of the current chunk was already behind the total size, loading a new chunk is not necessary
if (m_currentChunkEnd >= m_totalSize)
{
// We've reached the end of the file, but there might still be data in the zlib buffer.
m_zStream.avail_out = remainingBytes;
m_zStream.next_out = reinterpret_cast<Bytef*>(toFill + totalBytesRead);

int ret;
do { // emptying remaining data in zlib buffer
ret = inflate(&m_zStream, Z_NO_FLUSH);
if (ret == Z_STREAM_END) {
// Reached end of compressed data
unsigned long bytesRead = remainingBytes - m_zStream.avail_out;
totalBytesRead += bytesRead;
m_position += bytesRead;
remainingBytes = m_zStream.avail_out;
break;
}
else if (ret == Z_OK) {
// toFill is full
unsigned long bytesRead = remainingBytes - m_zStream.avail_out;
totalBytesRead += bytesRead;
m_position += bytesRead;
remainingBytes = m_zStream.avail_out;
break;
}
else if (ret != Z_BUF_ERROR) {
OPENMS_LOG_ERROR << "Error occurred during decompression. Zlib error code: " << ret << std::endl;
break;
}
} while (true);
return static_cast<XMLSize_t>(totalBytesRead);
}
// we reached the end of the current chunk
// load next chunk
m_req.SetRange("bytes=" + std::to_string(m_currentChunkEnd + 1) + "-" + std::to_string(m_currentChunkEnd + m_chunkSize));
m_currentChunkEnd = m_currentChunkEnd + m_chunkSize;
Aws::S3::Model::GetObjectOutcome outcome = m_client.GetObject(m_req);
if (outcome.IsSuccess()) {
m_currentChunk = outcome.GetResultWithOwnership();
currentBodyStream = &m_currentChunk.GetBody();
} else {
OPENMS_LOG_ERROR << "Error loading chunk from S3: " << outcome.GetError().GetExceptionName() << ": " << outcome.GetError().GetMessage() << std::endl;
}
}
else
{ // neither good nor eof -> error
OPENMS_LOG_ERROR << "Error in AWS S3 SDK result stream: " << currentBodyStream->rdstate() << std::endl;
}
}
return static_cast<XMLSize_t>(totalBytesRead);
}

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 | 🟠 Major

Same infinite loop issues exist in Gzip readBytes.

The Gzip variant has the same potential infinite loop issues as the base class when:

  1. Stream enters error state (neither good nor eof) - line 322-325
  2. Chunk fetch fails - lines 318-320

These should also break out of the loop on failure.

🐛 Proposed fix for lines 318-325
                 if (outcome.IsSuccess()) {
                     m_currentChunk = outcome.GetResultWithOwnership();
                     currentBodyStream = &m_currentChunk.GetBody();
                 } else {
                     OPENMS_LOG_ERROR << "Error loading chunk from S3: " << outcome.GetError().GetExceptionName() << ": " << outcome.GetError().GetMessage() << std::endl;
+                    break;
                 }
             }
             else
             { // neither good nor eof -> error
                 OPENMS_LOG_ERROR << "Error in AWS S3 SDK result stream: " << currentBodyStream->rdstate() << std::endl;
+                break;
             }
🧰 Tools
🪛 GitHub Check: CodeFactor

[notice] 228-329: src/openms/source/FORMAT/DATAACCESS/S3ChunkedInputSource.cpp#L228-L329
Complex Method

🤖 Prompt for AI Agents
In `@src/openms/source/FORMAT/DATAACCESS/S3ChunkedInputSource.cpp` around lines
228 - 328, The Gzip variant S3ChunkedGzipBinInputStream::readBytes can hang in
its outer while loop when the currentBodyStream enters an error state or when
fetching the next chunk fails; update the branches handling failed chunk fetch
(where outcome.IsSuccess() is false) and the "neither good nor eof" branch
(checking currentBodyStream->rdstate()) to break or return immediately (e.g.,
break out of the outer loop or return totalBytesRead) instead of only logging,
so the function doesn't spin forever; specifically modify the failure path after
m_client.GetObject(outcome) and the error-state branch to stop processing (use
break/return) and ensure any needed cleanup or final inflate draining happens
before returning.

Comment on lines +373 to +472
XMLSize_t S3ChunkedBzip2BinInputStream::readBytes(XMLByte* const toFill, const XMLSize_t maxToRead) {
auto currentBodyStream = &m_currentChunk.GetBody();
unsigned long totalBytesRead = 0;
// while maxToRead is not reached
while (totalBytesRead < maxToRead) {
unsigned long remainingBytes = maxToRead - totalBytesRead;
// read from current chunk
if (currentBodyStream->good())
{
do {
m_bzStream.avail_out = remainingBytes;
m_bzStream.next_out = reinterpret_cast<char*>(toFill + totalBytesRead);

if (m_bzStream.avail_in == 0)
{ // no bytes from last call in the bzip2 buffer anymore.
// Read more from current chunk if available
if (currentBodyStream->good()) {
currentBodyStream->read(reinterpret_cast<char*>(m_decompressedBuffer), 1024);
m_bzStream.avail_in = currentBodyStream->gcount();
m_bzStream.next_in = reinterpret_cast<char*>(m_decompressedBuffer);
}
else {
// Handle error or end of stream
break;
}
}

int ret = BZ2_bzDecompress(&m_bzStream);
if (ret == BZ_STREAM_END) {
// Reached end of compressed data
unsigned long bytesRead = remainingBytes - m_bzStream.avail_out;
totalBytesRead += bytesRead;
m_position += bytesRead;
remainingBytes = m_bzStream.avail_out;
break;
}
else if (ret != BZ_OK) {
OPENMS_LOG_ERROR << "Error occurred during decompression. Bzip2 error code: " << ret << std::endl;
break;
}

unsigned long bytesRead = remainingBytes - m_bzStream.avail_out;
totalBytesRead += bytesRead;
m_position += bytesRead;
remainingBytes = m_bzStream.avail_out; // Update remainingBytes after each call to inflate
} while (remainingBytes > 0); // Continue the loop while there is still space in toFill
}
else if (currentBodyStream->eof())
{
// if the end of the current chunk was already behind the total size, loading a new chunk is not necessary
if (m_currentChunkEnd >= m_totalSize)
{
// We've reached the end of the file, but there might still be data in the bzip2 buffer.
m_bzStream.avail_out = remainingBytes;
m_bzStream.next_out = reinterpret_cast<char*>(toFill + totalBytesRead);

int ret;
do { // emptying remaining data in bzip2 buffer
ret = BZ2_bzDecompress(&m_bzStream);
if (ret == BZ_STREAM_END) {
// Reached end of compressed data
unsigned long bytesRead = remainingBytes - m_bzStream.avail_out;
totalBytesRead += bytesRead;
m_position += bytesRead;
remainingBytes = m_bzStream.avail_out;
break;
}
else if (ret == BZ_OK) {
// toFill is full
unsigned long bytesRead = remainingBytes - m_bzStream.avail_out;
totalBytesRead += bytesRead;
m_position += bytesRead;
remainingBytes = m_bzStream.avail_out;
break;
}
else if (ret != BZ_OK && ret != BZ_STREAM_END) {
OPENMS_LOG_ERROR << "Error occurred during decompression. Bzip2 error code: " << ret << std::endl;
break;
}
} while (true);
return static_cast<XMLSize_t>(totalBytesRead);
}
// we reached the end of the current chunk
// load next chunk
m_req.SetRange("bytes=" + std::to_string(m_currentChunkEnd + 1) + "-" + std::to_string(m_currentChunkEnd + m_chunkSize));
m_currentChunkEnd = m_currentChunkEnd + m_chunkSize;
Aws::S3::Model::GetObjectOutcome outcome = m_client.GetObject(m_req);
if (outcome.IsSuccess()) {
m_currentChunk = outcome.GetResultWithOwnership();
currentBodyStream = &m_currentChunk.GetBody();
} else {
OPENMS_LOG_ERROR << "Error loading chunk from S3: " << outcome.GetError().GetExceptionName() << ": " << outcome.GetError().GetMessage() << std::endl;
}
}
else
{ // neither good nor eof -> error
OPENMS_LOG_ERROR << "Error in AWS S3 SDK result stream: " << currentBodyStream->rdstate() << std::endl;
}
}
return static_cast<XMLSize_t>(totalBytesRead);

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 | 🟠 Major

Same infinite loop issues exist in Bzip2 readBytes.

Identical to the Gzip and base variants - needs break statements on error conditions at lines 463-465 and 467-470.

🐛 Proposed fix for lines 463-470
                 if (outcome.IsSuccess()) {
                     m_currentChunk = outcome.GetResultWithOwnership();
                     currentBodyStream = &m_currentChunk.GetBody();
                 } else {
                     OPENMS_LOG_ERROR << "Error loading chunk from S3: " << outcome.GetError().GetExceptionName() << ": " << outcome.GetError().GetMessage() << std::endl;
+                    break;
                 }
             }
             else
             { // neither good nor eof -> error
                 OPENMS_LOG_ERROR << "Error in AWS S3 SDK result stream: " << currentBodyStream->rdstate() << std::endl;
+                break;
             }
🧰 Tools
🪛 GitHub Check: CodeFactor

[notice] 373-474: src/openms/source/FORMAT/DATAACCESS/S3ChunkedInputSource.cpp#L373-L474
Complex Method

🤖 Prompt for AI Agents
In `@src/openms/source/FORMAT/DATAACCESS/S3ChunkedInputSource.cpp` around lines
373 - 472, The read loop in S3ChunkedBzip2BinInputStream::readBytes can spin
forever on decompression and S3 errors because error paths (BZ2_bzDecompress
returning non-BZ_OK and S3 GetObject failures / stream errors) only log but do
not break/return; update the error branches that log via OPENMS_LOG_ERROR (the
branches handling ret != BZ_OK after BZ2_bzDecompress, and the S3
outcome.IsSuccess() false / stream rdstate() error paths) to exit the outer read
loop immediately (either break out to return totalBytesRead or return
static_cast<XMLSize_t>(totalBytesRead)) so the function stops trying to read
after an unrecoverable error; ensure you reference m_bzStream, BZ2_bzDecompress,
currentBodyStream, m_client.GetObject/outcome, and m_req when applying the
fixes.

Comment on lines +111 to +128
void S3InputSource::parseS3Uri_(std::string s3Uri) {
// Remove the "s3://" prefix if present
if (s3Uri.compare(0, 5, "s3://") == 0) {
s3Uri = s3Uri.substr(5);
}

// Find the first occurrence of '/' character
size_t slashPos = s3Uri.find('/');
if (slashPos == std::string::npos) {
throw std::runtime_error("Invalid S3 URI format: missing '/' after bucket name in '" + s3Uri + "'");
}

m_bucketName = s3Uri.substr(0, slashPos);
m_objectKey = s3Uri.substr(slashPos + 1);

if (m_bucketName.empty() || m_objectKey.empty()) {
throw std::runtime_error("Invalid S3 URI: bucket name or object key is empty");
}

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 | 🟠 Major

Use OpenMS exception types for S3 URI validation.

Throwing std::runtime_error skips OpenMS error metadata and standard exception handling.

✅ Suggested fix (Exception::Base-derived)
+#include <OpenMS/CONCEPT/Exception.h>
@@
-        if (slashPos == std::string::npos) {
-            throw std::runtime_error("Invalid S3 URI format: missing '/' after bucket name in '" + s3Uri + "'");
-        }
+        if (slashPos == std::string::npos) {
+            throw Exception::IllegalArgument(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
+                "Invalid S3 URI format: missing '/' after bucket name in '" + s3Uri + "'");
+        }
@@
-        if (m_bucketName.empty() || m_objectKey.empty()) {
-            throw std::runtime_error("Invalid S3 URI: bucket name or object key is empty");
-        }
+        if (m_bucketName.empty() || m_objectKey.empty()) {
+            throw Exception::IllegalArgument(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
+                "Invalid S3 URI: bucket name or object key is empty");
+        }

As per coding guidelines, use OpenMS::Exception::Base-derived exceptions with OPENMS_PRETTY_FUNCTION.

🤖 Prompt for AI Agents
In `@src/openms/source/FORMAT/DATAACCESS/S3InputSource.cpp` around lines 111 -
128, Replace the std::runtime_error throws in S3InputSource::parseS3Uri_ with
OpenMS Exception::Base-derived exceptions (e.g., OpenMS::Exception or a more
specific subclass) and include OPENMS_PRETTY_FUNCTION in the exception
construction; specifically, when slashPos == npos throw an OpenMS exception
indicating "Invalid S3 URI format: missing '/' after bucket name" and when
m_bucketName or m_objectKey is empty throw an OpenMS exception indicating
"Invalid S3 URI: bucket name or object key is empty", using the same text
context but constructed via the OpenMS exception class and passing
OPENMS_PRETTY_FUNCTION to preserve metadata.

Comment on lines +190 to +221
XMLSize_t S3GzipBinInputStream::readBytes(XMLByte* const toFill, const XMLSize_t maxToRead) {
m_zStream.avail_out = static_cast<uInt>(maxToRead);
m_zStream.next_out = reinterpret_cast<Bytef*>(toFill);

// although maxToRead is usually 48kB we cannot know for sure
// and must loop over smaller fixed buffer sizes for decompression
while (m_zStream.avail_out > 0) {
// Read more data from the stream
if (m_zStream.avail_in == 0) {
m_stream->read(reinterpret_cast<char*>(m_buffer), sizeof(m_buffer));
std::streamsize bytesRead = m_stream->gcount();
m_position += bytesRead;

m_zStream.avail_in = static_cast<uInt>(bytesRead);
m_zStream.next_in = m_buffer;
}

int result = inflate(&m_zStream, Z_NO_FLUSH);
if (result == Z_STREAM_END) {
// Reached the end of the compressed data
break;
} else if (result != Z_OK) {
// Error occurred during decompression
// Handle error
OPENMS_LOG_ERROR << "Error occurred during decompression. Zlib error message: " << (m_zStream.msg ? m_zStream.msg : "unknown") << std::endl;
return 0;
}
}

XMLSize_t bytesRead = maxToRead - m_zStream.avail_out;
return bytesRead;
}

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 | 🟠 Major

curPos() should track decompressed bytes, not compressed input.

Right now m_position advances by compressed bytes read, which under-reports the parser position for gzip/bzip streams.

🧭 Suggested fix for gzip/bzip position tracking
@@
-                    std::streamsize bytesRead = m_stream->gcount();
-                    m_position += bytesRead;
+                    std::streamsize bytesRead = m_stream->gcount();
@@
-            XMLSize_t bytesRead = maxToRead - m_zStream.avail_out;
-            return bytesRead;
+            XMLSize_t bytesRead = maxToRead - m_zStream.avail_out;
+            m_position += bytesRead;
+            return bytesRead;
@@
-                std::streamsize bytesRead = m_stream->gcount();
-                m_position += bytesRead;
+                std::streamsize bytesRead = m_stream->gcount();
@@
-        XMLSize_t bytesRead = maxToRead - m_bzStream.avail_out;
-        return bytesRead;
+        XMLSize_t bytesRead = maxToRead - m_bzStream.avail_out;
+        m_position += bytesRead;
+        return bytesRead;

Also applies to: 245-270

@jpfeuffer

Copy link
Copy Markdown
Contributor

Oops quite some valid issues. I will address them over time. Thanks for rebasing.

Copilot AI added a commit that referenced this pull request May 3, 2026
Support loading XML files (mzML, etc.) from remote locations:
- HTTP/HTTPS/FTP via Xerces URLInputSource
- S3 via AWS SDK (optional, WITH_S3=ON)

Features:
- S3 streaming with auto-decompression (gzip, bzip2)
- Compression detection via magic bytes or Content-Encoding header
- IndexedMzML support for S3 via range requests
- Network URI support in DocumentIdentifier

Based on PR #8671 by @jpfeuffer/@timosachsenberg with review fixes:
- Fixed PRIVATE keyword in cmake list(APPEND)
- Added OPENMS_DLLAPI to all public classes
- Added Doxygen documentation throughout
- Added override keywords consistently
- Fixed infinite loops (break on stream/fetch errors)
- Fixed error handling in stream constructors
- Uses larger (4096) decompression buffers

Agent-Logs-Url: https://github.com/OpenMS/OpenMS/sessions/9cd62545-8f51-4bfb-9d37-0c4e65f8cab9

Co-authored-by: jpfeuffer <[email protected]>
# Conflicts:
#	CMakeLists.txt
#	cmake/cmake_findExternalLibs.cmake
#	src/openms/source/FORMAT/DATAACCESS/sources.cmake
#	src/openms/source/FORMAT/HANDLERS/IndexedMzMLDecoder.cpp
#	src/openms/source/FORMAT/HANDLERS/XMLHandler.cpp
#	src/openms/source/FORMAT/XMLFile.cpp
#	src/openms/source/METADATA/DocumentIdentifier.cpp

Copy link
Copy Markdown
Contributor Author

Adversarial review result: blocking test issue.

The PR adds MzMLFile_test sections that load hard-coded s3://jpmstest/... objects and require AWS credentials plus network access whenever WITH_S3 is enabled. That makes the normal class test suite depend on external bucket state and credentials. These need to be moved behind an explicitly opt-in integration-test gate or replaced with mocked/local coverage.

Cleanup: git diff --check also reports trailing whitespace in src/openms/source/FORMAT/DATAACCESS/S3InputSource.cpp. I did not build/run tests locally.

@jpfeuffer

Copy link
Copy Markdown
Contributor

This test was disabled and only left as a placeholder. We cannot test S3 unless you spawn a companion minio container in CI. Up to you. For me it sounds overkill for such a rarely used experimental feature for now

@jpfeuffer

jpfeuffer commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor

haha wait was the difference between this and #9262?

@timosachsenberg
timosachsenberg marked this pull request as draft September 21, 2026 16:29

@timosachsenberg timosachsenberg left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The existing stream-error findings remain substantive blockers: the uncompressed S3 constructor continues after failed GetObject/invalid ContentRange, and the chunked read loops can continue without progress on stream errors. I verified those paths in the current diff and am not duplicating the inline threads. Both build and Python workflows failed; their logs are expired. No live S3 or local build test was performed.

Copy link
Copy Markdown
Contributor Author

Closing in favour of #9262, which reimplements this on top of current develop and carries the review feedback from here (including the xerces/curl vcpkg overlay). Remote XML loading continues there.


Generated by Claude Code

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