Skip to content

fix: provider cache path handling in Windows#5788

Merged
denis256 merged 4 commits intomainfrom
windows-provider-cache
Apr 2, 2026
Merged

fix: provider cache path handling in Windows#5788
denis256 merged 4 commits intomainfrom
windows-provider-cache

Conversation

@denis256
Copy link
Copy Markdown
Member

@denis256 denis256 commented Apr 2, 2026

Description

  • Fixed provider cache path checking

Before

image

After

image

TODOs

Read the Gruntwork contribution guidelines.

  • I authored this code entirely myself
  • I am submitting code based on open source software (e.g. MIT, MPL-2.0, Apache)]
  • I am adding or upgrading a dependency or adapted code and confirm it has a compatible open source license
  • Update the docs.
  • Run the relevant tests successfully, including pre-commit checks.
  • Include release notes. If this PR is backward incompatible, include a migration guide.

Release Notes (draft)

Added / Removed / Updated [X].

Migration Guide

Summary by CodeRabbit

  • Bug Fixes
    • Provider cache on Windows now correctly distinguishes remote URLs from local file paths, avoiding invalid path checks and preventing unintended removal of existing local archives.
  • Tests
    • Added a Windows-only integration test and fixture to validate provider-cache behavior with remote URLs.
  • Documentation
    • Updated changelog to v1.0.1 describing the Windows provider-cache fix.

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 2, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
terragrunt-docs Ready Ready Preview, Comment Apr 2, 2026 6:21pm

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 2, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0c248218-9d75-45d3-9ace-40e2cc6b36f6

📥 Commits

Reviewing files that changed from the base of the PR and between e97a734 and 0b00c52.

📒 Files selected for processing (1)
  • internal/tf/cache/services/provider_cache.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • internal/tf/cache/services/provider_cache.go

📝 Walkthrough

Walkthrough

Warm-up now distinguishes local filesystem paths from remote URLs by checking for "://"; local files set archivePath without download, remote URLs use existing download/retry. Cleanup no longer removes archivePath unless archive was cached. Adds Windows test fixtures, integration test, and changelog entry.

Changes

Cohort / File(s) Summary
Provider Cache Logic
internal/tf/cache/services/provider_cache.go
Add isLocalFile helper; warmUp skips vfs.FileExists for remote URLs (detects "://"), set cache.archivePath directly for existing local files, retain download+retry for remote URLs; startProviderCaching avoids removing archivePath unless archiveCached is true.
Windows Test Fixtures
test/fixtures/provider-cache/windows-remote-url/main.tf, test/fixtures/provider-cache/windows-remote-url/terragrunt.hcl
Add Terraform fixture pinning hashicorp/null v3.2.4 and an empty terragrunt.hcl to exercise remote URL provider-cache behavior on Windows.
Windows Integration Test
test/integration_windows_test.go
Add TestWindowsProviderCacheWithRemoteURL and fixture constant to run terragrunt init with --provider-cache and assert cache directory populated.
Changelog
docs/src/data/changelog/v1.0.1.mdx
Update frontmatter to v1.0.1 and add entry describing the Windows-specific fix that skips filesystem checks for remote provider download URLs.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The description includes before/after images demonstrating the fix and has checklist items marked complete, but lacks detailed explanation of what was changed and the actual release notes content is incomplete. Provide a clear textual explanation of the changes made (beyond images), such as the isLocalFile helper and archivePath logic, and fill out the release notes with a one-line description instead of the placeholder text.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: fixing provider cache path handling specifically for Windows, which is the core issue addressed in the PR.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch windows-provider-cache

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@denis256 denis256 marked this pull request as ready for review April 2, 2026 17:26
@denis256 denis256 changed the title fix: fixed provider cache path checking fix: provider cache path handling in Windows Apr 2, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@internal/tf/cache/services/provider_cache.go`:
- Around line 335-337: The code currently repoints cache.archivePath to
cache.DownloadURL when downloadURLIsLocalFile, but later cleanup removes
cache.archivePath unconditionally which can delete user-provided files; modify
the logic so that when downloadURLIsLocalFile is true you mark the archive as
user-provided (e.g., set a boolean like cache.archiveIsUserProvided or
cache.shouldCleanupArchive=false) and ensure the cleanup routine that removes
cache.archivePath (the block referenced around the existing cleanup) checks that
flag (or the inverse of downloadURLIsLocalFile) before deleting; update any
constructors/structs to include the flag and use it in the cleanup path so only
temporary downloaded archives are removed.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 82f65c94-c321-4438-b2fd-a704434d8185

📥 Commits

Reviewing files that changed from the base of the PR and between f23ce5f and 49bfa07.

📒 Files selected for processing (4)
  • internal/tf/cache/services/provider_cache.go
  • test/fixtures/provider-cache/windows-remote-url/main.tf
  • test/fixtures/provider-cache/windows-remote-url/terragrunt.hcl
  • test/integration_windows_test.go

return errors.New(err)
// DownloadURL can be a local file path or a remote URL.
// On Windows, passing a URL to FileExists fails because the colon in "https:" is invalid path syntax.
var downloadURLIsLocalFile bool
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: I feel like this would be better served as a private function call.

yhakbar
yhakbar previously approved these changes Apr 2, 2026
Copy link
Copy Markdown
Collaborator

@yhakbar yhakbar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure to update the changelog too:
https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/data/changelog/unreleased.mdx

Feel free to rename the file to v1.0.0.mdx when you edit it.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/src/data/changelog/v1.0.1.mdx`:
- Around line 48-49: Update the sentence on line 48 to accurately reflect the
code path: replace the claim that the URL was passed to os.Stat with wording
that the remote URL reached the vfs.FileExists check (which calls fs.Stat
underneath) in provider_cache.go; mention vfs.FileExists and fs.Stat to make the
documentation precise about where the filesystem existence check is skipped for
URLs containing "://".
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 77ce32c9-bfe2-40a3-ae16-055a7aac2f05

📥 Commits

Reviewing files that changed from the base of the PR and between 49bfa07 and e97a734.

📒 Files selected for processing (1)
  • docs/src/data/changelog/v1.0.1.mdx

Comment on lines +48 to +49
The provider cache failed on Windows with `CreateFile https://...: The filename, directory name, or volume label syntax is incorrect` because remote download URLs were passed to `os.Stat`, and the colon in `https:` is invalid Windows path syntax. The fix skips the filesystem existence check when the download URL is a remote URL (`://`), going directly to the download path.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Tighten Line 48 wording to match the actual code path.

Line 48 says the URL was passed to os.Stat, but the implementation guards vfs.FileExists (which calls fs.Stat underneath). Updating this avoids implying a direct os.Stat call in provider_cache.go.

Suggested docs wording
-The provider cache failed on Windows with `CreateFile https://...: The filename, directory name, or volume label syntax is incorrect` because remote download URLs were passed to `os.Stat`, and the colon in `https:` is invalid Windows path syntax. The fix skips the filesystem existence check when the download URL is a remote URL (`://`), going directly to the download path.
+The provider cache failed on Windows with `CreateFile https://...: The filename, directory name, or volume label syntax is incorrect` because remote download URLs were being treated like local filesystem paths during existence checks (`vfs.FileExists`/`fs.Stat`), and the colon in `https:` is invalid Windows path syntax. The fix skips the filesystem existence check when the download URL is remote (`://`) and proceeds directly with provider download/caching.

As per coding guidelines docs/**/*.md*: documentation should be clear and accurate.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
The provider cache failed on Windows with `CreateFile https://...: The filename, directory name, or volume label syntax is incorrect` because remote download URLs were passed to `os.Stat`, and the colon in `https:` is invalid Windows path syntax. The fix skips the filesystem existence check when the download URL is a remote URL (`://`), going directly to the download path.
The provider cache failed on Windows with `CreateFile https://...: The filename, directory name, or volume label syntax is incorrect` because remote download URLs were being treated like local filesystem paths during existence checks (`vfs.FileExists`/`fs.Stat`), and the colon in `https:` is invalid Windows path syntax. The fix skips the filesystem existence check when the download URL is remote (`://`) and proceeds directly with provider download/caching.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/src/data/changelog/v1.0.1.mdx` around lines 48 - 49, Update the sentence
on line 48 to accurately reflect the code path: replace the claim that the URL
was passed to os.Stat with wording that the remote URL reached the
vfs.FileExists check (which calls fs.Stat underneath) in provider_cache.go;
mention vfs.FileExists and fs.Stat to make the documentation precise about where
the filesystem existence check is skipped for URLs containing "://".

yhakbar
yhakbar previously approved these changes Apr 2, 2026
@denis256 denis256 merged commit 1ee0396 into main Apr 2, 2026
27 of 28 checks passed
@denis256 denis256 deleted the windows-provider-cache branch April 2, 2026 18:35
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.

2 participants