Skip to content

Fix loading CML files with imports via relative paths (#364) - #388

Draft
stefan-ka wants to merge 1 commit into
masterfrom
fix/364-relative-path-imports
Draft

stefan-ka wants to merge 1 commit into
masterfrom
fix/364-relative-path-imports

Conversation

@stefan-ka

@stefan-ka stefan-ka commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

Fixes the crash reported in #364.

Cause

StandaloneContextMapper.loadCML(String) created the resource URI with URI.createURI(filepath). For a plain (relative) file path like ContextMap.cml, this yields a relative URI. CMLImportResolver then resolves each import against the resource URI, which fails with IllegalArgumentException: resolve against non-hierarchical or relative base, e.g. in cm generate -g plantuml -i ContextMap.cml (the CLI calls loadCML(String)).

Fix

Plain file paths (no URI scheme, or a single-letter scheme = Windows drive letter) are converted into absolute file URIs, as loadCML(File) already does. Strings that are already URIs (file:, platform:, …) are used as before.

Test

StandaloneAPITest.canLoadCMLWithImportsViaRelativePathAndCallGenerator loads a context map that imports its Bounded Contexts from a second file via a relative path and calls the PlantUML generator. Verified that it fails without the fix and passes with it.

Not addressed

The issue also mentions that the VS Code extension only generates the context map diagram for such models (no Aggregate diagrams), and a comment mentions null names in diagrams caused by the global scope provider. Those are separate problems in the scoping/import handling and are not touched here.

Based on master plus the Gradle/Jacoco build fix from #383 (same commit content, cherry-picked), so it can be merged independently.

@codecov

codecov Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 60.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.8%. Comparing base (17d16de) to head (4dc235d).

Files with missing lines Patch % Lines
...mapper/dsl/standalone/StandaloneContextMapper.java 60.0% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             master    #388     +/-   ##
==========================================
- Coverage      91.8%   91.8%   -0.1%     
- Complexity     2230    2231      +1     
==========================================
  Files           211     211             
  Lines          5942    5946      +4     
  Branches        807     808      +1     
==========================================
+ Hits           5458    5460      +2     
- Misses          230     231      +1     
- Partials        254     255      +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

StandaloneContextMapper.loadCML(String) created a relative URI from a
plain file path. Resolving the imports of such a resource against its URI
failed with 'resolve against non-hierarchical or relative base', e.g.
when generating PlantUML diagrams with the CLI.

Plain file paths are now converted into absolute file URIs; strings that
already are URIs (file:, platform:, ...) are used as before.
@stefan-ka
stefan-ka force-pushed the fix/364-relative-path-imports branch from 9c8f20b to 4dc235d Compare October 20, 2026 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant