Skip to content

fix(scaffold): preserve source in scaffold config - #2869

Merged
Erik Osterman (Cloud Posse) (osterman) merged 3 commits into
cloudposse:mainfrom
jorrite:fix-scaffold-source
Aug 11, 2026
Merged

Erik Osterman (Cloud Posse) (osterman) merged 3 commits into
cloudposse:mainfrom
jorrite:fix-scaffold-source

Conversation

@jorrite

@jorrite Jorrit Elfferich (jorrite) commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

what

  • Fix atmos scaffold generate/atmos init recording a dangling, already-deleted temp-directory path in spec.source of .atmos/scaffold.yaml whenever the template source is remote (git::... or a bare https://... URL).
  • In the filepkg/generator/source/resolver.go: in resolveRemote(), set conf.Source = src (the original source string the caller passed in) after loading the template configuration from the temporary download directory, instead of leaving Configuration.Source as whatever LoadConfigurationFromDir was given (the temp dir itself).
  • pkg/generator/source/resolver_test.go: added/extended tests asserting Configuration.Source holds the original source for both local and remote paths, plus a dedicated regression test (TestResolve_RemoteRecordsOriginalSource) that fails on the pre-fix code and passes after.
  • No change to local source handling (resolveLocal), which already recorded the correct value.

why

  • For a remote scaffold source, resolveRemote() downloads the template into os.MkdirTemp("", "atmos-scaffold-"), then loaded the config with that temp dir passed in as the "source" — so Configuration.Source, and
    therefore the persisted spec.source, ended up holding something like /var/folders/xx/.../atmos-scaffold-1234567890. That directory is removed by cleanup() immediately after the command finishes, so the recorded provenance is a dangling reference to nothing as soon as generation completes — useless for anything that might want to read it back later (e.g. a future --update/re-resolve flow), and directly contradicts SaveProjectRecord's own doc comment: "spec.source and spec.baseRef record provenance for future updates."
  • Local sources (a relative/absolute path, or file://...) were correct only by accident of not having a temp-dir indirection step in resolveLocal, not because anything special-cased provenance for them.
  • Reproduced directly: atmos scaffold generate "git::https://.../scaffold-template.git" ./out --defaults, then cat ./out/.atmos/scaffold.yaml shows a /var/folders/...//tmp/... path for spec.source, and that path no longer exists on disk.

references

  • No upstream GitHub issue — checked issue search and the web for cloudposse/atmos + spec.source/scaffold, nothing matched as of 2026-08.

@jorrite
Jorrit Elfferich (jorrite) requested a review from a team as a code owner August 5, 2026 13:00
@atmos-pro

atmos-pro Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Tip

Atmos Pro  

No affected stacks workflow was detected for this pull request.
If this is expected, no action is needed.
Learn More. Ask AI.

@github-actions github-actions Bot added the size/s Small size PR label Aug 5, 2026
@coderabbitai

coderabbitai Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 0e22d4d7-18e0-4aa2-a528-5a5804914f72

📥 Commits

Reviewing files that changed from the base of the PR and between f2d9362 and fb0795c.

📒 Files selected for processing (1)
  • docs/fixes/2026-08-10-scaffold-remote-source-provenance.md

📝 Walkthrough

Walkthrough

The resolver preserves the original source path or URI after local, hydrated, and remote scaffold resolution. Tests cover local source preservation and remote ZIP loading. Documentation records the remote provenance correction.

Changes

Source provenance

Layer / File(s) Summary
Resolver source preservation and validation
pkg/generator/source/resolver.go, pkg/generator/source/resolver_test.go, docs/fixes/...
Remote resolution records the caller-provided source URI instead of the temporary download directory. Tests verify local, hydrated, and remote source values. Documentation records the fix and validation results.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

Possibly related PRs

Suggested labels: patch

Suggested reviewers: aknysh

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: preserving the source in the scaffold configuration.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pkg/generator/source/resolver_test.go`:
- Around line 244-259: Update TestResolve_RemoteRecordsOriginalSource to avoid
invoking the git binary or requiring requireGit, initSourceTestGitRepo, or
runSourceTestGit. Use Go-native fixture files with a mocked fetcher, or move the
remote-source fixture setup into test-only implementation support, while
preserving the assertion that cfg.Source equals the original remote source
string.
🪄 Autofix

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 Plus

Run ID: 815c2a22-a02a-4869-b88b-6a464f49ceed

📥 Commits

Reviewing files that changed from the base of the PR and between c14ce82 and aade2ed.

📒 Files selected for processing (2)
  • pkg/generator/source/resolver.go
  • pkg/generator/source/resolver_test.go

Comment thread pkg/generator/source/resolver_test.go
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Aug 5, 2026
@jorrite Jorrit Elfferich (jorrite) changed the title fix: preserve source in scaffold config fix(scaffold): preserve source in scaffold config Aug 6, 2026
@codecov

codecov Bot commented Aug 6, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.78%. Comparing base (1107de3) to head (fb0795c).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2869   +/-   ##
=======================================
  Coverage   82.77%   82.78%           
=======================================
  Files        1863     1863           
  Lines      180609   180610    +1     
=======================================
+ Hits       149500   149510   +10     
+ Misses      23314    23303   -11     
- Partials     7795     7797    +2     
Flag Coverage Δ
unittests 82.78% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
pkg/generator/source/resolver.go 82.24% <100.00%> (+0.16%) ⬆️

... and 7 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@osterman Erik Osterman (Cloud Posse) (osterman) added the patch A minor, backward compatible change label Aug 11, 2026
@atmos-pro

atmos-pro Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Tip

Atmos Pro  

No affected stacks workflow was detected for this pull request.
If this is expected, no action is needed.
Learn More. Ask AI.

Merged via the queue into cloudposse:main with commit e5fe050 Aug 11, 2026
91 checks passed
@atmos-pro

atmos-pro Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Tip

Atmos Pro  

No affected stacks workflow was detected for this pull request.
If this is expected, no action is needed.
Learn More. Ask AI.

Igor Rodionov (goruha) added a commit that referenced this pull request Aug 11, 2026
…into 1199-pro-exec-metadata

* '1199-pro-exec-metadata' of github.com:cloudposse/atmos:
  Add task-runner dependencies, freshness checks, and preconditions to custom commands and workflows (#2882)
  feat(provisioner): Azure (azurerm) backend auto-provisioning (#2911)
  fix: preserve trailing newlines in text-based 3-way merges (#2891)
  fix(scaffold): preserve source in scaffold config (#2869)
  fix(deps): update github.com/epiclabs-io/diff3 digest to 3b16698 (#2917)
  fix(deps): update kubernetes monorepo to v0.36.3 (#2918)
@github-actions

Copy link
Copy Markdown

These changes were released in v1.226.0-rc.5.

@jorrite
Jorrit Elfferich (jorrite) deleted the fix-scaffold-source branch September 12, 2026 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch A minor, backward compatible change size/m Medium size PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants