Fix URI path parsing bug in FMU C++ template - preserve leading slash on Unix#111
Draft
Fix URI path parsing bug in FMU C++ template - preserve leading slash on Unix#111
Conversation
Co-authored-by: ClaasRostock <48752696+ClaasRostock@users.noreply.github.com>
Co-authored-by: ClaasRostock <48752696+ClaasRostock@users.noreply.github.com>
Co-authored-by: ClaasRostock <48752696+ClaasRostock@users.noreply.github.com>
Co-authored-by: ClaasRostock <48752696+ClaasRostock@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix URI path parsing bug in generated FMU C++ code
Fix URI path parsing bug in FMU C++ template - preserve leading slash on Unix
Jan 14, 2026
|
@copilot Checks are failing because |
Co-authored-by: magkri <17215215+magkri@users.noreply.github.com>
Author
Fixed in commit 75b70ea. Updated sourcery version constraint to |
|
@copilot Resolve all linting errors reported by |
Co-authored-by: magkri <17215215+magkri@users.noreply.github.com>
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The
formatOnnxPathfunction in the FMU C++ template incorrectly stripped 8 characters when removingfile://URI prefixes, causing loss of the leading/in Unix absolute paths. This prevented FMU instantiation when libraries like fmpy pass paths asfile:///tmp/path/model.onnx.Root cause: Checked for
"file:///"(8 chars) but stripped 8 chars, removing one char too many.Fix: Check for and strip
"file://"(7 chars) to preserve the leading/.Changes
C++ Template (
src/mlfmu/fmu_build/templates/onnx_fmu/onnxFmu.cpp):L"file:///"→L"file://"Test (
tests/test_uri_path_handling.py):ruff formatDependency Fix (
pyproject.toml):>=1.22to>=1.40,!=1.41.1Example
How Has This Been Tested?
Screenshots (if appropriate)
N/A
Developer Checklist (before requesting PR review)
I have:
Reviewer checklist
I have:
Original prompt
This section details on the original issue you should resolve
<issue_title>URI Path Parsing Bug in Generated FMU C++ Code - Missing Leading Slash on Unix</issue_title>
<issue_description>## Summary
MLFMU generates FMUs with a C++ path parsing bug that causes FMU instantiation to fail on Unix systems when using absolute paths. The bug is in the
formatOnnxPathfunction which incorrectly strips URI prefixes.Root Cause
In
mlfmu/fmu_build/templates/onnx_fmu/onnxFmu.cpp, theformatOnnxPathfunction has incorrect substring logic around lines 44-46:Problem Description
When
fmpy(and other FMU libraries) pass absolute paths to the FMU, they convert them tofile://URIs:file:///tmp/extracted_fmu/resources/model.onnx/tmp/extracted_fmu/resources/model.onnxtmp/extracted_fmu/resources/model.onnx❌ (missing leading/)This causes ONNX model loading to fail with:
Reproduction Case