Skip to content

fix(vendor): resolve relative vendor targets against the Atmos base_path - #2833

Open
thejrose1984 wants to merge 19 commits into
cloudposse:mainfrom
thejrose1984:claude/github-issue-2409-by4npj
Open

thejrose1984 wants to merge 19 commits into
cloudposse:mainfrom
thejrose1984:claude/github-issue-2409-by4npj

Conversation

@thejrose1984

@thejrose1984 thejrose1984 commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

what

  • Relative targets in a vendor manifest now resolve against the Atmos base_path when atmos.yaml declares the manifest's location via vendor.base_path. A manifest discovered in the working directory (no vendor.base_path configured) keeps resolving targets relative to itself, so the common single-directory layout is unchanged.
  • Absolute targets are used as-is. filepath.Join was nesting them under the base path, so /opt/x became opt/x.
  • A relative local source declared in an imported manifest now resolves against that manifest's directory instead of the root manifest's. Each source records the manifest that declared it as it's read, and local sources anchor to it — through any depth of nested imports.
  • determineSourceType now writes the anchored path back to its caller. It computed the path but rebound a local pointer (uri = &absPath), so the URI the package was actually downloaded from stayed relative and resolved against the process working directory.
  • atmos vendor pull now prints one line naming where relative targets resolve, and only when that is not the manifest's own directory — see "upgrade impact" below. The common layout, manifest at the base path, is unchanged and silent.
  • Docs: rewrote the targets and source resolution rules in website/docs/vendor/config/sources.mdx, added a "Relative paths in imported manifests" section to imports.mdx, and documented the vendor.base_path interaction in cli/configuration/vendor.mdx and cli/commands/vendor/vendor-pull.mdx.

Also included, unrelated to path resolution: os.Getuid() == 0 skip guards on five permission-dependent tests, and a tests.RequireTerraform(t) precondition on the hooks/store integration test. These make the suite pass in a root sandbox, where a read-only or 0o000 directory does not block the write the tests rely on.

Deliberately not changed: targets stay anchored to a single root for every source, imported or not. They describe where artifacts land in the project, so splitting a manifest into imports must not move them. The asymmetry with source is now documented rather than implicit.

why

  • Keeping atmos.yaml and vendor.yaml together in a config directory dropped the vendored components/terraform tree next to the manifest instead of under base_path, where components.terraform.base_path and stacks.base_path point. ExecuteAtmosVendorInternal joined every relative target to filepath.Dir(vendorConfigFileName).
  • The docs already described the fixed behavior — "if the vendor.yaml file is detected by Atmos using the base_path setting in atmos.yaml, the targets paths will be considered relative to the base_path" — the code never implemented it.
  • The imported-source gap was surfaced by CodeRabbit's reconciliation against docs/prd/base-path-resolution-semantics.md, whose core convention is that a relative path in a configuration file is anchored to the file declaring it. processVendorImports recorded provenance, but a single anchor built from the root manifest was handed to every merged source. The failure was not subtle: a manifest at vendor/mid.yaml declaring source: ./local-src looked for <root>/local-src, missed it, fell through to the remote path, and go-getter turned the relative path into https://./local-src. Vendoring failed outright.
  • Provenance is recorded in mergeVendorConfigFiles rather than processVendorImports because one import can name a directory of manifests, and each file in it anchors its own sources.

Testing

  • Offline end-to-end tests drive atmos vendor pull against generated projects: the config-directory layout from Vendored artefacts are targeted relative to the vendor.yaml file, not the base_path specified in atmos.yaml #2409, the no-vendor.base_path fallback, and a chain of nested imports where three manifests at three depths each vendor a sibling local-src whose marker file identifies it — so anchoring to the wrong manifest cannot accidentally pass. Each was confirmed to fail before the fix.
  • Unit tables cover both anchor helpers, provenance recording, per-target version overrides, and absolute targets.
  • Existing fixtures re-run against a built binary to check local sources didn't regress: vendor-simple-excludes --tags=simple, and the vendor fixture's --tags=dir (path-traversal source) and --tags=file (the file:// form, whose separate branch is untouched) all produce exactly the files tests/test-cases/vendor-test.yaml expects.
  • GOOS=windows go vet is clean, and absolute-path tests derive from t.TempDir() — a separator-rooted path like \opt\x is not absolute on Windows, so those assertions would otherwise have exercised the relative branch there.

Upgrade impact

For a project that already vendored successfully — a remote or absolute source plus vendor.base_path pointing outside the Atmos base path — relative targets now land in a different directory:

# before
./config/components/terraform/widget

# after
./components/terraform/widget

Both runs exit 0 and the previous tree is left in place, so the change would otherwise surface only as a large unexplained diff. vendor pull now names both directories once per run when they differ.

Projects hitting the bug this PR fixes (a relative local source in a manifest declared via vendor.base_path) were failing outright before, so they have nothing to relocate.

references

Summary by CodeRabbit

  • Bug Fixes

    • Fixed vendor pull resolution for relative targets using the configured Atmos base_path.
    • Preserved manifest-directory resolution when no vendor base path is configured.
    • Ensured relative sources resolve from the manifest that declares them, including imported manifests.
    • Absolute target paths are honored unchanged.
  • Documentation

    • Clarified source and target path resolution, including base_path, vendor.base_path, and imported manifests.

When `atmos.yaml` declares the vendor manifest location via `vendor.base_path`,
relative `targets` were joined to the directory containing `vendor.yaml`. Keeping
`atmos.yaml` and `vendor.yaml` in a config directory therefore dropped the
vendored `components/terraform` tree next to the manifest instead of under the
Atmos `base_path`, where `components.terraform.base_path` and `stacks.base_path`
point. This is the behavior the docs already described.

Targets now resolve against the Atmos `base_path` whenever the manifest location
comes from `vendor.base_path`. A manifest discovered in the working directory
(no `vendor.base_path` configured) keeps resolving targets relative to itself, so
the common single-directory layout is unchanged. Local `source` paths still
resolve relative to the manifest that declares them.

Also honor absolute `targets` as-is; `filepath.Join` was nesting them under the
base path even though absolute targets are documented as supported.

Fixes cloudposse#2409
@thejrose1984
thejrose1984 requested a review from a team as a code owner July 30, 2026 14:06
@atmos-pro

atmos-pro Bot commented Jul 30, 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/m Medium size PR label Jul 30, 2026
@coderabbitai

coderabbitai Bot commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

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: 0090bf94-4129-4efb-ab52-5c80f73daff9

📥 Commits

Reviewing files that changed from the base of the PR and between 1107de3 and be11af1.

📒 Files selected for processing (15)
  • cmd/env/env_test.go
  • cmd/root_process_chdir_test.go
  • internal/exec/vendor_paths.go
  • internal/exec/vendor_pull_integration_test.go
  • internal/exec/vendor_utils.go
  • internal/exec/vendor_utils_test.go
  • main_hooks_and_store_integration_test.go
  • main_plan_diff_integration_test.go
  • pkg/archive/archive_test.go
  • pkg/schema/schema.go
  • pkg/vendoring/install/copy_glob_unix_test.go
  • website/docs/cli/commands/vendor/vendor-pull.mdx
  • website/docs/cli/configuration/vendor.mdx
  • website/docs/vendor/config/imports.mdx
  • website/docs/vendor/config/sources.mdx
🚧 Files skipped from review as they are similar to previous changes (14)
  • pkg/schema/schema.go
  • main_plan_diff_integration_test.go
  • cmd/root_process_chdir_test.go
  • internal/exec/vendor_paths.go
  • pkg/vendoring/install/copy_glob_unix_test.go
  • website/docs/cli/configuration/vendor.mdx
  • website/docs/cli/commands/vendor/vendor-pull.mdx
  • cmd/env/env_test.go
  • main_hooks_and_store_integration_test.go
  • pkg/archive/archive_test.go
  • internal/exec/vendor_utils_test.go
  • internal/exec/vendor_utils.go
  • website/docs/vendor/config/sources.mdx
  • internal/exec/vendor_pull_integration_test.go

📝 Walkthrough

Walkthrough

Vendor pull resolves relative targets against Atmos base_path when configured. Without vendor.base_path, targets resolve against the vendor manifest directory. Relative sources resolve against their declaring manifest. Absolute targets remain unchanged.

Changes

Vendor path resolution

Layer / File(s) Summary
Path resolution contracts
internal/exec/vendor_paths.go, pkg/schema/schema.go, internal/exec/vendor_utils.go
Adds manifest lookup, source classification, manifest provenance, and target-base-path resolution.
Vendor pull provenance and propagation
internal/exec/vendor_utils.go
Tracks declaring manifest directories, preserves imported source provenance, and passes source and target base paths through vendor processing.
Path resolution validation and documentation
internal/exec/vendor_utils_test.go, internal/exec/vendor_pull_integration_test.go, website/docs/...
Tests configured and fallback target paths, imported-manifest sources, absolute targets, semver handling, and platform-safe paths. Documentation defines the same resolution rules.

Test environment portability

Layer / File(s) Summary
Environment-aware test prerequisites
cmd/env/env_test.go, cmd/root_process_chdir_test.go, pkg/archive/archive_test.go, pkg/vendoring/install/copy_glob_unix_test.go, main_hooks_and_store_integration_test.go, main_plan_diff_integration_test.go
Permission tests skip when root bypasses restrictions. Terraform integration tests require Terraform.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant VendorPull
  participant VendorUtils
  participant VendorManifest
  participant Filesystem
  VendorPull->>VendorUtils: Merge vendor sources
  VendorUtils->>VendorManifest: Read declaring manifest directory
  VendorUtils->>VendorUtils: Resolve source and target paths
  VendorUtils->>Filesystem: Write vendored artifacts
Loading

Possibly related PRs

Suggested labels: patch

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The pull request includes unrelated permission and Terraform test guards that are not required by issue #2409. Move unrelated permission and Terraform test guard changes into a separate pull request, or provide linked requirements for them.
Docstring Coverage ⚠️ Warning Docstring coverage is 62.86% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 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 primary change: resolving relative vendor targets against Atmos base_path.
Linked Issues check ✅ Passed The changes satisfy issue #2409 by resolving relative vendor targets against Atmos base_path when configured and preserving absolute targets.
✨ 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 `@internal/exec/vendor_utils_test.go`:
- Around line 1002-1038: Update both test sites in
internal/exec/vendor_utils_test.go (lines 1002-1038 and 1080-1111) to derive
absTarget from t.TempDir() instead of joining filepath.Separator with fixed path
components. Use that real platform-specific absolute path in each target-path
test while preserving the existing expected behavior and assertions.
🪄 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 Plus

Run ID: f669d52f-2541-45f2-bce7-cc5d36169f0d

📥 Commits

Reviewing files that changed from the base of the PR and between 6f92049 and 42d1d11.

📒 Files selected for processing (6)
  • internal/exec/vendor_pull_integration_test.go
  • internal/exec/vendor_utils.go
  • internal/exec/vendor_utils_test.go
  • website/docs/cli/commands/vendor/vendor-pull.mdx
  • website/docs/cli/configuration/vendor.mdx
  • website/docs/vendor/config/sources.mdx

Comment thread internal/exec/vendor_utils_test.go Resolved
`filepath.Join(string(filepath.Separator), "opt", ...)` produces `\opt\...` on
Windows, which `filepath.IsAbs` rejects because it carries no volume name. The
absolute-target assertions would therefore have exercised the relative branch and
failed on Windows CI. Derive the path from `t.TempDir()` instead, and guard the
precondition with `require.True(filepath.IsAbs(...))` so a future regression fails
loudly rather than silently testing the wrong branch.

Also add doc comments to the new test functions.
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 30, 2026
@osterman

Copy link
Copy Markdown
Member

CodeRabbit (@coderabbitai) please reconcile against our PRDs for relative path handling

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo="cloudposse/atmos"

echo "== Issue `#2409` =="
gh issue view 2409 --repo "$repo" --comments

echo
echo "== PR `#2833` metadata and comments =="
gh pr view 2833 --repo "$repo" --comments

echo
echo "== Locate potential PRD/relative-path documentation =="
rg -n -i -C 2 'PRD|product requirements|relative path|base_path|vendor\.base_path|vendor\.yaml' \
  README.md docs website internal 2>/dev/null || true

echo
echo "== Resolver outline =="
ast-grep outline internal/exec/vendor_utils.go --items all --view expanded

echo
echo "== Relevant resolver implementation =="
rg -n -C 12 'resolveVendorTargetBasePath|resolveVendorTargetPath|TargetBasePath|VendorConfigFilePath' \
  internal/exec/vendor_utils.go

echo
echo "== Changed documentation =="
for f in \
  website/docs/cli/commands/vendor/vendor-pull.mdx \
  website/docs/cli/configuration/vendor.mdx \
  website/docs/vendor/config/sources.mdx
do
  echo "--- $f ---"
  rg -n -C 8 'target|base_path|relative|absolute' "$f" || true
done

Length of output: 200937


🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo="cloudposse/atmos"

echo "== Issue `#2409`, bounded =="
gh issue view 2409 --repo "$repo" --json number,title,body,url,comments \
  --jq '{number,title,url,body,comments:[.comments[]|{author:.author.login,body,url}]}'

echo
echo "== PR `#2833`, bounded =="
gh pr view 2833 --repo "$repo" --json number,title,body,url,comments,reviewThreads \
  --jq '{number,title,url,body,comments:[.comments[]|{author:.author.login,body,url}],reviewThreads:[.reviewThreads[]|{isResolved,comments:[.comments[]|{author:.author.login,body,path,line,url}]}]}'

echo
echo "== Candidate PRDs =="
fd -t f . docs/prd 2>/dev/null | sort || true
rg -n -i -C 4 'vendor|relative path|base_path|target' docs/prd 2>/dev/null || true

echo
echo "== Import processing and local-source resolution =="
sed -n '500,640p' internal/exec/vendor_utils.go
echo "--- unit test outline ---"
ast-grep outline internal/exec/vendor_utils_test.go --items all --view expanded
echo "--- import/local-source tests and calls ---"
rg -n -C 8 'processVendorImports|determineSourceType|SourceIsLocalFile|local.*source|imports?' \
  internal/exec/vendor_utils_test.go internal/exec/vendor_pull_integration_test.go

Length of output: 6572


🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo="cloudposse/atmos"

echo "== PR `#2833` =="
gh pr view 2833 --repo "$repo" --json number,title,body,url,comments,reviews,files \
  --jq '{number,title,url,body,comments:[.comments[]|{author:.author.login,body,url}],reviews:[.reviews[]|{author:.author.login,state,body,url}],files:[.files[].path]}'

echo
echo "== Inline review comments =="
gh api "repos/${repo}/pulls/2833/comments?per_page=100" \
  --jq '.[] | {user:.user.login, path, line, body, html_url}' || true

echo
echo "== Import behavior: implementation =="
sed -n '245,395p' internal/exec/vendor_utils.go
sed -n '500,555p' internal/exec/vendor_utils.go
sed -n '584,625p' internal/exec/vendor_utils.go

echo
echo "== Import/local-source coverage =="
rg -n -C 10 'processVendorImports|imports:|SourceIsLocalFile|determineSourceType|source:.*(\./|\.\./)|local' \
  internal/exec/vendor_utils_test.go internal/exec/vendor_pull_integration_test.go

echo
echo "== PRD candidate files =="
fd -t f . docs/prd 2>/dev/null | sort | head -n 200

Length of output: 60742


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Base-path semantics PRD =="
rg -n -C 8 -i 'relative|absolute|base.path|manifest|vendor|source|target|import' \
  docs/prd/base-path-resolution-semantics.md

echo
echo "== Import provenance PRDs =="
for f in docs/prd/import-provenance.md docs/prd/provenance-import-resolution.md; do
  echo "--- $f ---"
  rg -n -C 8 -i 'relative|absolute|path|manifest|declaring|provenance|source|target|import' "$f"
done

echo
echo "== Existing provenance model =="
rg -n -C 6 'AtmosVendorSource|\.File\b|SourceFile|Origin|Provenance|declaring manifest' \
  internal pkg | head -n 500

Length of output: 91884


@osterman Reconciled against #2409 and the relative-path PRDs.

Aligned

  • The primary fix satisfies #2409: when vendor.base_path configures the manifest, relative targets resolve from Atmos base_path.
  • Absolute targets pass through unchanged, consistent with FR5 in docs/prd/base-path-resolution-semantics.md.
  • The fallback for a discovered, unconfigured manifest remains manifest-relative, preserving prior behavior.

Gap — imported local sources

  • The PR states that local source paths remain relative to the manifest that declares them. This is not true for an imported manifest.
  • processVendorImports records the imported manifest in AtmosVendorSource.File, but Line 274–291 creates one vendorConfigFilePath from the root manifest and supplies it for every merged source.
  • Line 588–625 then resolves every relative local source against that root directory.

Thus, if vendor.yaml imports vendor/modules/network.yaml, and that imported file declares source: ./fixture, Atmos resolves it relative to the root vendor.yaml, rather than vendor/modules/network.yaml.

This conflicts with the PRD’s core convention: a relative path defined in a configuration file is anchored to the directory of the file that declares it. The target behavior is correct; imported-source provenance needs to be carried into source resolution, with coverage for nested imports.

You are interacting with an AI system.

@aknysh

Copy link
Copy Markdown
Member

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain
🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo="cloudposse/atmos"

echo "== Issue `#2409` =="
gh issue view 2409 --repo "$repo" --comments

echo
echo "== PR `#2833` metadata and comments =="
gh pr view 2833 --repo "$repo" --comments

echo
echo "== Locate potential PRD/relative-path documentation =="
rg -n -i -C 2 'PRD|product requirements|relative path|base_path|vendor\.base_path|vendor\.yaml' \
  README.md docs website internal 2>/dev/null || true

echo
echo "== Resolver outline =="
ast-grep outline internal/exec/vendor_utils.go --items all --view expanded

echo
echo "== Relevant resolver implementation =="
rg -n -C 12 'resolveVendorTargetBasePath|resolveVendorTargetPath|TargetBasePath|VendorConfigFilePath' \
  internal/exec/vendor_utils.go

echo
echo "== Changed documentation =="
for f in \
  website/docs/cli/commands/vendor/vendor-pull.mdx \
  website/docs/cli/configuration/vendor.mdx \
  website/docs/vendor/config/sources.mdx
do
  echo "--- $f ---"
  rg -n -C 8 'target|base_path|relative|absolute' "$f" || true
done

Length of output: 200937

🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo="cloudposse/atmos"

echo "== Issue `#2409`, bounded =="
gh issue view 2409 --repo "$repo" --json number,title,body,url,comments \
  --jq '{number,title,url,body,comments:[.comments[]|{author:.author.login,body,url}]}'

echo
echo "== PR `#2833`, bounded =="
gh pr view 2833 --repo "$repo" --json number,title,body,url,comments,reviewThreads \
  --jq '{number,title,url,body,comments:[.comments[]|{author:.author.login,body,url}],reviewThreads:[.reviewThreads[]|{isResolved,comments:[.comments[]|{author:.author.login,body,path,line,url}]}]}'

echo
echo "== Candidate PRDs =="
fd -t f . docs/prd 2>/dev/null | sort || true
rg -n -i -C 4 'vendor|relative path|base_path|target' docs/prd 2>/dev/null || true

echo
echo "== Import processing and local-source resolution =="
sed -n '500,640p' internal/exec/vendor_utils.go
echo "--- unit test outline ---"
ast-grep outline internal/exec/vendor_utils_test.go --items all --view expanded
echo "--- import/local-source tests and calls ---"
rg -n -C 8 'processVendorImports|determineSourceType|SourceIsLocalFile|local.*source|imports?' \
  internal/exec/vendor_utils_test.go internal/exec/vendor_pull_integration_test.go

Length of output: 6572

🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo="cloudposse/atmos"

echo "== PR `#2833` =="
gh pr view 2833 --repo "$repo" --json number,title,body,url,comments,reviews,files \
  --jq '{number,title,url,body,comments:[.comments[]|{author:.author.login,body,url}],reviews:[.reviews[]|{author:.author.login,state,body,url}],files:[.files[].path]}'

echo
echo "== Inline review comments =="
gh api "repos/${repo}/pulls/2833/comments?per_page=100" \
  --jq '.[] | {user:.user.login, path, line, body, html_url}' || true

echo
echo "== Import behavior: implementation =="
sed -n '245,395p' internal/exec/vendor_utils.go
sed -n '500,555p' internal/exec/vendor_utils.go
sed -n '584,625p' internal/exec/vendor_utils.go

echo
echo "== Import/local-source coverage =="
rg -n -C 10 'processVendorImports|imports:|SourceIsLocalFile|determineSourceType|source:.*(\./|\.\./)|local' \
  internal/exec/vendor_utils_test.go internal/exec/vendor_pull_integration_test.go

echo
echo "== PRD candidate files =="
fd -t f . docs/prd 2>/dev/null | sort | head -n 200

Length of output: 60742

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Base-path semantics PRD =="
rg -n -C 8 -i 'relative|absolute|base.path|manifest|vendor|source|target|import' \
  docs/prd/base-path-resolution-semantics.md

echo
echo "== Import provenance PRDs =="
for f in docs/prd/import-provenance.md docs/prd/provenance-import-resolution.md; do
  echo "--- $f ---"
  rg -n -C 8 -i 'relative|absolute|path|manifest|declaring|provenance|source|target|import' "$f"
done

echo
echo "== Existing provenance model =="
rg -n -C 6 'AtmosVendorSource|\.File\b|SourceFile|Origin|Provenance|declaring manifest' \
  internal pkg | head -n 500

Length of output: 91884

@osterman Reconciled against #2409 and the relative-path PRDs.

Aligned

  • The primary fix satisfies #2409: when vendor.base_path configures the manifest, relative targets resolve from Atmos base_path.
  • Absolute targets pass through unchanged, consistent with FR5 in docs/prd/base-path-resolution-semantics.md.
  • The fallback for a discovered, unconfigured manifest remains manifest-relative, preserving prior behavior.

Gap — imported local sources

  • The PR states that local source paths remain relative to the manifest that declares them. This is not true for an imported manifest.
  • processVendorImports records the imported manifest in AtmosVendorSource.File, but Line 274–291 creates one vendorConfigFilePath from the root manifest and supplies it for every merged source.
  • Line 588–625 then resolves every relative local source against that root directory.

Thus, if vendor.yaml imports vendor/modules/network.yaml, and that imported file declares source: ./fixture, Atmos resolves it relative to the root vendor.yaml, rather than vendor/modules/network.yaml.

This conflicts with the PRD’s core convention: a relative path defined in a configuration file is anchored to the directory of the file that declares it. The target behavior is correct; imported-source provenance needs to be carried into source resolution, with coverage for nested imports.

You are interacting with an AI system.

thejrose1984 please analyze this review and address the concerns

@codecov

codecov Bot commented Jul 30, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.11765% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.78%. Comparing base (1107de3) to head (be11af1).
⚠️ Report is 579 commits behind head on main.

Files with missing lines Patch % Lines
internal/exec/vendor_paths.go 90.90% 3 Missing and 2 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2833      +/-   ##
==========================================
+ Coverage   82.77%   82.78%   +0.01%     
==========================================
  Files        1863     1864       +1     
  Lines      180609   180640      +31     
==========================================
+ Hits       149500   149544      +44     
+ Misses      23314    23301      -13     
  Partials     7795     7795              
Flag Coverage Δ
unittests 82.78% <94.11%> (+0.01%) ⬆️

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

Files with missing lines Coverage Δ
internal/exec/vendor_utils.go 77.13% <100.00%> (-0.14%) ⬇️
pkg/schema/schema.go 86.42% <ø> (ø)
internal/exec/vendor_paths.go 90.90% <90.90%> (ø)

... and 6 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.

…fest

Sources merged in from `spec.imports` were all resolved against the root
manifest's directory. A manifest at `vendor/mid.yaml` declaring
`source: ./local-src` looked for `<root>/local-src`, missed it, fell through to
the remote path, and go-getter turned the relative path into
`https://./local-src` — vendoring failed outright.

Record the declaring manifest per source while manifests are read, and anchor
relative local sources to it, so a manifest stays self-contained no matter which
manifest imports it or how deeply. Provenance is recorded in mergeVendorConfigFiles
rather than processVendorImports because one import can name a directory of
manifests, and each file in it anchors its own sources.

determineSourceType resolved the anchored path but rebound its local pointer
instead of writing through, so the caller kept the relative URI and the download
resolved it against the process working directory. Write it back, and return
before url.Parse now that the URI is a filesystem path — parsing it as a URL
would read a Windows drive letter as a scheme.

Targets are deliberately left anchored to one root for every source, imported or
not: they describe where artifacts land in the project, so splitting a manifest
into imports must not move them.

Renames processTargetsParams.VendorConfigFilePath to SourceBasePath so it reads as
the pair to TargetBasePath.
Claude (claude) and others added 2 commits August 1, 2026 10:43
This PR pushed internal/exec/vendor_utils.go from 589 to 673 lines, past the
600-line limit in CLAUDE.md, and the file is not on the revive
file-length-limit exception list.

Move the three path-resolution questions into vendor_paths.go — where the
manifest is, where a relative source points, where a relative target lands — and
document at the top why sources and targets resolve differently. Pure move: the
only change to vendor_utils.go is dropping the now-unused net/url import.
vendor_utils.go is back to 550 lines, below where this PR found it.

Also drop the loop in processVendorImports that overwrote each imported source's
File with the raw import path. Sources now record the manifest they were read
from in mergeVendorConfigFiles, which is more precise when an import names a
directory of manifests, and no longer clobbers a `file` a source declares
itself. Error messages are unchanged for the common case, where the import path
and the resolved manifest path are the same string.

@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 `@cmd/env/env_test.go`:
- Around line 356-360: Replace direct os.Getuid() calls in cmd/env/env_test.go
lines 356-360 and cmd/root_process_chdir_test.go lines 108-111 with a shared
OS-specific root-detection helper. Implement the helper to use Unix root
detection on supported platforms and return false on Windows, then keep the
existing skip behavior based on that helper.
🪄 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 Plus

Run ID: a82f89a6-b4a9-47f8-8758-986000b8206b

📥 Commits

Reviewing files that changed from the base of the PR and between de8bcef and 6acb1e9.

📒 Files selected for processing (2)
  • cmd/env/env_test.go
  • cmd/root_process_chdir_test.go

Comment thread cmd/env/env_test.go Resolved
@mergify

mergify Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

💥 This pull request now has conflicts. Could you fix it thejrose1984? 🙏

Reconcile the vendor base-path anchoring in this PR with main's vendor
refactor (per-target semver-range version overrides + the install package):

- processTargetsParams / vendorSourceParams keep main's version-override
  fields (install.PkgType, RawVersion, RefreshLock, Lister) alongside this
  PR's split anchors (SourceBasePath for local sources, TargetBasePath for
  targets), replacing the single VendorConfigFilePath anchor.
- resolveAtmosVendorSource and resolveTargetOverride classify sources against
  the declaring manifest (resolveVendorSourceBasePath); processTargets
  resolves targets with resolveVendorTargetPath (absolute targets honored)
  and keeps main's filepath.Abs for the lock containment check.
- determineSourceType / resolveVendorConfigFilePath now live only in
  vendor_paths.go; main's copies (including the uri=&absPath bug this PR
  fixes) are dropped.
- Test literals updated to the split-anchor fields and install.PkgType*, and
  the target-path assertions account for the absolute paths processTargets
  now returns.
@coderabbitai

coderabbitai Bot commented Aug 6, 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.

@mergify mergify Bot removed the conflict This PR has conflicts label Aug 6, 2026

@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.

🧹 Nitpick comments (1)
internal/exec/vendor_paths.go (1)

113-132: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use the package error contract for source parsing failures.

Wrap both failures with a static error from errors/errors.go and add source URI context. Line 116 creates a dynamic error. Line 132 returns the parser error without context. This prevents callers from classifying the error consistently.

As per coding guidelines, “Wrap all errors with static errors from errors/errors.go” and “never use dynamic errors directly.”

🤖 Prompt for 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.

In `@internal/exec/vendor_paths.go` around lines 113 - 132, The source parsing
failure paths in the vendor URI handling must use the package’s static errors
from errors/errors.go and include the offending URI as context. Update the error
returned after JoinPathAndValidate and the url.Parse failure in the surrounding
source-parsing flow, reusing the appropriate predefined error symbols and
wrapping the underlying errors rather than returning dynamic or parser errors
directly.

Source: Coding guidelines

🤖 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.

Nitpick comments:
In `@internal/exec/vendor_paths.go`:
- Around line 113-132: The source parsing failure paths in the vendor URI
handling must use the package’s static errors from errors/errors.go and include
the offending URI as context. Update the error returned after
JoinPathAndValidate and the url.Parse failure in the surrounding source-parsing
flow, reusing the appropriate predefined error symbols and wrapping the
underlying errors rather than returning dynamic or parser errors directly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 35dffb60-6948-4a09-945b-536bf824899b

📥 Commits

Reviewing files that changed from the base of the PR and between 3ce4349 and bbe2b07.

📒 Files selected for processing (15)
  • cmd/env/env_test.go
  • cmd/root_process_chdir_test.go
  • internal/exec/vendor_paths.go
  • internal/exec/vendor_pull_integration_test.go
  • internal/exec/vendor_utils.go
  • internal/exec/vendor_utils_test.go
  • main_hooks_and_store_integration_test.go
  • main_plan_diff_integration_test.go
  • pkg/archive/archive_test.go
  • pkg/schema/schema.go
  • pkg/vendoring/install/copy_glob_unix_test.go
  • website/docs/cli/commands/vendor/vendor-pull.mdx
  • website/docs/cli/configuration/vendor.mdx
  • website/docs/vendor/config/imports.mdx
  • website/docs/vendor/config/sources.mdx
🚧 Files skipped from review as they are similar to previous changes (5)
  • cmd/root_process_chdir_test.go
  • pkg/schema/schema.go
  • website/docs/cli/commands/vendor/vendor-pull.mdx
  • website/docs/cli/configuration/vendor.mdx
  • cmd/env/env_test.go

coderabbitai[bot]
coderabbitai Bot previously approved these changes Aug 7, 2026
@thejrose1984

Copy link
Copy Markdown
Contributor Author

Andriy Knysh (@aknysh) Rebased on main and worked through all three items — branch head is now bbe2b07c, and the PR is mergeable again.

1. Merge conflicts (vendor refactor ↔ base-path anchoring). main's per-target semver-range version overrides and the new install package collided with this PR's SourceBasePath/TargetBasePath split in vendor_utils.go + its tests. Reconciled by keeping both:

  • processTargetsParams/vendorSourceParams carry main's version fields (install.PkgType, RawVersion, RefreshLock, Lister) alongside this PR's split anchors, replacing the single VendorConfigFilePath.
  • resolveAtmosVendorSource and resolveTargetOverride classify sources against the declaring manifest (resolveVendorSourceBasePath); processTargets resolves targets with resolveVendorTargetPath (absolute targets honored) and keeps main's filepath.Abs for the lock-containment check.
  • determineSourceType/resolveVendorConfigFilePath now live only in vendor_paths.go; main's copies — including the uri = &absPath bug this PR fixes — are dropped.

Verified locally: go build ./... clean, GOOS=windows go vet clean, and the vendor unit + integration suites pass (TestVendorPullTargetsResolveAgainstBasePath, ...RelativeToManifestWithoutVendorBasePath, ...ImportedManifestAnchorsItsOwnLocalSources, the per-target version-override tests, and TestProcessTargets_*).

2. os.Getuid on Windows (CodeRabbit, critical). Verified false positive and resolved the thread with the details: os.Getuid() is cross-platform (returns -1 on Windows; only syscall.Getuid is Unix-only), GOOS=windows go vet ./cmd/... compiles clean, both call sites already t.Skip on Windows before that line, and the same pattern is already used in cmd/terraform/workdir/workdir_helpers_test.go. Offered to add a shared skipIfRoot(t) helper if you'd like it purely for consistency.

3. The failed Windows test ([mock-windows] .../complete, vpc-mixin-2/-4). That run was on the pre-rebase commit. Those two are local file sources; I reproduced the exact path on macOS against the merged code and all of vpc-mixin-2/3/4 vendor correctly (both context.tf and the renamed context-copy.tf land). The merge also pulls in main's latest install-package copy logic. I can't run the Windows job locally, so could you approve CI so it re-runs on bbe2b07c? If the Windows copy still fails there, I'll dig into the Windows-specific path handling.

…nifest dir

Anchoring relative targets to the Atmos `base_path` moves vendored artifacts
for any project that already worked and kept its manifest outside the base
path — a remote or absolute `source` plus `vendor.base_path`. Both the old and
new runs exit 0, the previous tree is left in place rather than cleaned up,
and the only record of the move was a Debug-level log line, so the upgrade
shows up as a large unexplained diff.

Print one line per run naming both directories, and only when they differ —
so the common layout, where the manifest sits at the base path, is unchanged
and silent:

    ▶ Vendoring from 'config/vendor.yaml'
    ▶ Relative targets resolve against the Atmos base path '.', not the
      manifest directory 'config'

Kept in logInitialMessage rather than resolveVendorTargetBasePath so the
resolver stays a pure function and UI stays on the UI path.

Co-Authored-By: Claude Opus 5 <[email protected]>
@github-actions github-actions Bot added size/l Large size PR and removed size/m Medium size PR labels Aug 9, 2026
@thejrose1984

Copy link
Copy Markdown
Contributor Author

Code RabBit (@CodeRabbit) review

@coderabbitai

coderabbitai Bot commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Aug 9, 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.

@mergify

mergify Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

💥 This pull request now has conflicts. Could you fix it thejrose1984? 🙏

@mergify mergify Bot added the conflict This PR has conflicts label Aug 11, 2026
@github-actions

github-actions Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Quality Gate   Quality Gate not ready

Readiness

✅ Ready for review

⚠️ No merge conflicts — This PR has merge conflicts with its target branch.

⚠️ Release label and milestone — The PR's release label or milestone does not satisfy the release policy.

✅ Verified commit signatures

✅ Fewer than 150 changed files

Reviews

✅ CodeRabbit approval (current head)

✅ Review threads resolved or dismissed

Measures

⚠️ All CI checks and workflows — 3 CI results are unsuccessful; 0 are still pending.

✅ Codecov (current head)

✅ Benchmark results

View job summary

Current commit: be11af1af99f54efc791aeb2f98765948c2b2356 · quality:not-ready

Quality Gate details
Gate Status Evidence
Ready for review Passed Marked ready for review
No merge conflicts Not ready Merge conflicts with the target branch
Release label and milestone Not ready release milestone policy: PR #2833 requires a release milestone
All CI checks and workflows Not ready check: github-actions/[mock-windows] tests/fixtures/scenarios/complete: failure; status: Release milestone: failure; workflow: .github/workflows/test.yml: failure
Codecov (current head) Passed codecov/patch: success; codecov/project: success
CodeRabbit approval (current head) Passed APPROVED
Verified commit signatures Passed 19/19 commits have GitHub-verified signatures
Review threads resolved or dismissed Passed 0 unresolved review threads (outdated threads still count)
Fewer than 150 changed files Passed 15 changed files; maximum 149
Benchmark results Passed No benchmark report processing error recorded for this head
🤖 Next steps for this PR
PR: https://github.com/cloudposse/atmos/pull/2833
Head: be11af1af99f54efc791aeb2f98765948c2b2356

1. No merge conflicts
   Problem: This PR has merge conflicts with its target branch.
   Next: Rebase the PR branch onto its target branch or merge that branch into it, resolve the conflicts, and push.
   Evidence: https://github.com/cloudposse/atmos/pull/2833/conflicts

2. Release label and milestone
   Problem: The PR's release label or milestone does not satisfy the release policy.
   Next: Apply exactly one of major, minor, patch, or no-release. Except for no-release, assign a stable-version milestone. Only the lowest open release milestone may merge, and its bump from the latest published stable release must accommodate the label (patch may enter minor; minor may not enter patch). Preserve the intended release: wait for earlier milestones to ship rather than moving a PR merely to clear this gate.
   Evidence: https://github.com/cloudposse/atmos/pull/2833

3. All CI checks and workflows
   Problem: 3 CI results are unsuccessful; 0 are still pending.
   Next: Open the logs for the unsuccessful results listed below. Fix the reported cause and rerun those jobs; for cancelled or infrastructure-failed jobs, verify the cause before retrying.
   Observed results (quoted data):
   - "check: github-actions/[mock-windows] tests/fixtures/scenarios/complete": "failure"
   - "status: Release milestone": "failure"
   - "workflow: .github/workflows/test.yml": "failure"
   Evidence: https://github.com/cloudposse/atmos/pull/2833/checks

@github-actions github-actions Bot added the quality:not-ready One or more Quality Gate requirements are pending or failing label Oct 11, 2026

This branch was previously deployed

1 inactive deployment
screengrabs — be11af1a Deployed Aug 10, 2026 by thejrose1984 via build #1240
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conflict This PR has conflicts patch A minor, backward compatible change quality:not-ready One or more Quality Gate requirements are pending or failing size/l Large size PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vendored artefacts are targeted relative to the vendor.yaml file, not the base_path specified in atmos.yaml

4 participants