Skip to content

Skip object store folder creation when no storage access - #9634

Merged
Martin-Molinero merged 1 commit into
QuantConnect:masterfrom
Martin-Molinero:bug-object-store-no-access-skip-folder-creation
Jul 23, 2026
Merged

Skip object store folder creation when no storage access#9634
Martin-Molinero merged 1 commit into
QuantConnect:masterfrom
Martin-Molinero:bug-object-store-no-access-skip-folder-creation

Conversation

@Martin-Molinero

Copy link
Copy Markdown
Member

Description

LocalObjectStore.Initialize created the storage root directory unconditionally, and did so before Controls were even assigned. On environments where the process lacks permission to the target path (e.g. a read-only /Storage mount), this threw an UnauthorizedAccessException during engine startup even for jobs that have no storage access at all:

System.UnauthorizedAccessException: Access to the path '/Storage' is denied.
 ---> System.IO.IOException: Permission denied
   at System.IO.Directory.CreateDirectory(String path)
   at QuantConnect.Lean.Engine.Storage.LocalObjectStore.Initialize(...)

Changes

  • Assign Controls and _algorithmMode before resolving the storage root.
  • Only create the root directory when StorageAccess is null (backwards-compatible default) or grants at least one of read/write/delete. This matches the permission checks that already guard every disk-touching operation (ContainsKey/ReadBytes/SaveBytes/Delete/enumeration), so when all permissions are false nothing ever reaches the folder.
  • When access is fully denied, AlgorithmStorageRoot is still normalized via Path.GetFullPath (no filesystem write) so later path comparisons remain consistent with the FullName-normalized form used elsewhere.

Related Issue

N/A

LocalObjectStore.Initialize created the storage root directory
unconditionally, before Controls were even assigned. On environments
where the process lacks permission to the target path this threw an
UnauthorizedAccessException even for jobs with no storage access at all.

Now Controls are assigned first and the root directory is only created
when StorageAccess is null or grants at least one of read/write/delete,
matching the permission checks already guarding every disk operation.
When access is fully denied the path is still normalized via
Path.GetFullPath so later comparisons remain consistent.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Martin-Molinero
Martin-Molinero merged commit cd52034 into QuantConnect:master Jul 23, 2026
7 of 8 checks passed
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.

1 participant