Skip to content

Resolve a relative --store path instead of aborting startup [patch] - #103

Merged
matt-edmondson merged 2 commits into
mainfrom
fix/93-resolve-relative-store
Oct 9, 2026
Merged

matt-edmondson merged 2 commits into
mainfrom
fix/93-resolve-relative-store

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #93

What was wrong

The tool copied --store verbatim into GitLfsCache:Store:Root, and the options validator requires a fully qualified root. So gitlfscache --store ./cache ..., the obvious way to run it locally, aborted at startup with an unhandled OptionsValidationException and a stack trace.

Change

  • Program.ResolveStoreRoot resolves the flag with Path.GetFullPath, the same way --config is already handled.
  • The validator's absolute-path rule is unchanged. Configuration-file and environment sources stay strict for container deployments.

Tests

  • StoreFlagTests.Store_RelativeDirectory_ResolvesAgainstTheWorkingDirectory: ./cache resolves to <cwd>/cache, which is fully qualified. The test fails when the helper passes the value through unchanged, as the code did before.
  • StoreFlagTests.Store_FullyQualifiedDirectory_IsKeptAsGiven: an absolute path is left alone.
  • Manual check: I ran the built tool from a temporary directory with the repro from the issue (--port 5197 --store ./relcache --upstream stub=http://127.0.0.1:5199 --allow 'stub=**'). It started, created ./relcache, and kept serving until it was stopped, with no stack trace.

The full suite passes locally: 356 tests, 0 failed. The optional "catch OptionsValidationException and print plain lines" item is not included.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Md2Tr7FWcbqPdwq2BjeG79


Generated by Claude Code

The tool copied --store verbatim into GitLfsCache:Store:Root, and the options
validator requires a fully qualified root, so `gitlfscache --store ./cache`
failed at startup with an unhandled OptionsValidationException.

The flag is now resolved against the working directory with
Path.GetFullPath, the same way --config is. The validator's absolute-path
rule is unchanged, so configuration files and environment variables stay
strict for container deployments.

Fixes #93

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Md2Tr7FWcbqPdwq2BjeG79
SonarCloud's new-code coverage gate counted the changed line in Main's
command action as uncovered, since no test reached Main. Main is now
internal and a test runs it with a relative --store and an invalid
--upstream, which reads every flag and then exits 1 before a server starts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Md2Tr7FWcbqPdwq2BjeG79
@sonarqubecloud

sonarqubecloud Bot commented Oct 8, 2026

Copy link
Copy Markdown

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.

gitlfscache --store ./cache aborts with an unhandled OptionsValidationException stack trace instead of resolving the relative path like --config does

2 participants