feat: configurable root path for read-only environments #26
+94
−4
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.
Summary
MarkItDownPathResolverhardcodes.markitdownunderEnvironment.CurrentDirectory, which is read-only in Azure Functions (and similar containerized/serverless environments), crashing on the first conversion.Lazy<string>in the resolver with a lock-guarded double-check init pattern and added aConfigure(string)method so the root can be redirected before any conversion runs.MarkItDownOptions.RootPathfor non-DI callers andMarkItDownServiceBuilder.UseRootPath()for DI callers.Usage
DI (Program.cs):
Non-DI:
Safety
Configure()andRootPathfirst-access share a single lock -- no race window between writing the config and materializing the root.InvalidOperationExceptioninstead of silently ignoring.Path.GetFullPath()with platform-aware comparison (case-insensitive on Windows, ordinal on Linux).Files changed
src/MarkItDown/Utilities/MarkItDownPathResolver.cs-- core fix (lock-guarded init +Configure)src/MarkItDown/Core/MarkItDownOptions.cs-- addedRootPathpropertysrc/MarkItDown/Core/MarkItDownClient.cs-- 2 lines wiringRootPathin constructorsrc/MarkItDown/DependencyInjection/MarkItDownServiceBuilder.cs-- addedUseRootPath()methodAGENTS.md-- documented the configurability ruleTest plan
RootPathto temp folder resolves the crash