Skip to content

fix(config): resolve git-root base_path for --config/--config-path - #2864

Merged
Andriy Knysh (aknysh) merged 9 commits into
mainfrom
osterman/fix-issue-2863
Aug 4, 2026
Merged

Andriy Knysh (aknysh) merged 9 commits into
mainfrom
osterman/fix-issue-2863

Conversation

@osterman

@osterman Erik Osterman (Cloud Posse) (osterman) commented Aug 4, 2026 •

Copy link
Copy Markdown
Member

what

  • Fixes pkg/config/load_config_args.go so that loading configuration via --config/--config-path also applies git-root discovery for an empty (or .) base_path, matching the plain auto-discovery flow in LoadConfig().
  • Adds a regression test (TestLoadConfigFromCLIArgs_AppliesGitRootBasePath) that reproduces the bug and verifies base_path now resolves correctly.
  • Bumps the fast-uri transitive dependency (website) from 3.1.4 to 3.1.5 to remediate a high-severity host-confusion vulnerability (GHSA-7p8r-x3mc-p8w7 / CVE-2026-18446), flagged by Dependabot after this branch was pushed.

why

  • loadConfigFromCLIArgs() never called applyGitRootBasePath(), unlike the main LoadConfig() auto-discovery path. As a result, a project with base_path: '' in atmos.yaml resolved correctly via plain auto-discovery but left base_path empty when the identical config was loaded via --config, breaking component/stack path resolution (e.g. atmos terraform test) with Error: failed to find import.
  • The fast-uri bump addresses a live Dependabot alert (a patch-level version bump, not blocked by .github/dependabot.yml's major-version ignore policy) surfaced automatically after pushing this branch.

references

Summary by CodeRabbit

  • Bug Fixes

    • Configuration loaded through command-line options now resolves an empty or "." base path to the Git repository root.
    • Configuration loading continues when repository root discovery encounters an error.
    • Improved ZIP extraction safety by blocking path traversal and preventing writes outside the intended destination.
    • Improved error reporting for ZIP directory and file creation failures.
  • Tests

    • Added coverage for configuration base-path resolution and ZIP extraction security and failure handling.

…onfig-path

loadConfigFromCLIArgs skipped applyGitRootBasePath, so an empty base_path
in atmos.yaml never resolved to the git repository root when config was
loaded via --config/--config-path, unlike plain auto-discovery. This broke
component/stack path resolution for commands like `atmos terraform test`.

Closes #2863

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Patches a host-confusion vulnerability in fast-uri (CVE-2026-18446, high
severity) where a backslash authority introducer is parsed differently
than Node's WHATWG URL, allowing host-policy bypass. 3.1.4 -> 3.1.5 is a
patch-level bump, not blocked by dependabot.yml's major-version ignore rule.

Addresses Dependabot alert #262.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@atmos-pro

atmos-pro Bot commented Aug 4, 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.

@osterman Erik Osterman (Cloud Posse) (osterman) added the patch A minor, backward compatible change label Aug 4, 2026
@github-actions github-actions Bot added the size/s Small size PR label Aug 4, 2026
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues found.

Scanned Files

  • website/pnpm-lock.yaml

@coderabbitai

coderabbitai Bot commented Aug 4, 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
📝 Walkthrough

Walkthrough

CLI configuration now resolves empty or dot-relative base_path values to the Git repository root. ZIP extraction rejects traversal entries and revalidates destination containment before filesystem operations. The website package updates its fast-uri override.

Changes

CLI base path resolution

Layer / File(s) Summary
Git root resolution for CLI configuration
pkg/config/load_config_args.go, pkg/config/git_root.go, pkg/config/load_config_args_test.go
CLI configuration loading uses an overridable Git-root resolver, applies Git-root discovery, and logs discovery errors without aborting. Tests cover file and directory inputs, empty or "." base paths, and resolver failures.

ZIP extraction containment checks

Layer / File(s) Summary
Revalidate ZIP extraction paths
pkg/toolchain/pr_artifact.go, pkg/toolchain/pr_artifact_test.go
ZIP extraction rejects raw .. entries and checks directory, parent-directory, and file paths against the destination root before filesystem operations. Tests cover containment boundaries and extraction failures.

Website dependency override

Layer / File(s) Summary
Update fast-uri override
website/package.json
The pnpm override changes fast-uri@^3 from ^3.1.4 to ^3.1.5.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: aknysh

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The fast-uri override update is unrelated to issue #2863 and adds scope beyond the linked configuration fix. Move the fast-uri security update to a separate pull request or link an issue that explicitly requires it.
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% 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 describes the primary change to resolve Git-root base paths for --config and --config-path.
Linked Issues check ✅ Passed The CLI configuration path now resolves empty or '.' base_path values through Git-root discovery and adds regression tests, satisfying issue #2863.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch osterman/fix-issue-2863

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/config/load_config_args_test.go`:
- Line 151: Add table-driven test cases in the existing configuration argument
test covering AtmosConfigDirsFromArg and the default base_path value "." in
addition to the current AtmosConfigFilesFromArg case with an empty base path.
Ensure each CLI input and both base-path behaviors are exercised independently
using the existing test structure.
🪄 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: 7f60c957-4af3-47a2-b6ac-ac86ede67387

📥 Commits

Reviewing files that changed from the base of the PR and between b1124da and e931734.

⛔ Files ignored due to path filters (1)
  • website/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (3)
  • pkg/config/load_config_args.go
  • pkg/config/load_config_args_test.go
  • website/package.json

Comment thread pkg/config/load_config_args_test.go Resolved
CodeQL alert #5230 (go/zipslip) remained open against pkg/toolchain/pr_artifact.go
even though the file already sanitizes archive entry paths in multiple layers
(sanitizeZipPath, plus a prior filepath.Rel guard added specifically to satisfy
this same scanner). The common thread across the flagged lines is that the
containment check happened earlier in the caller rather than directly guarding
each sink (os.MkdirAll x2, os.Create inside extractZipEntry, which previously
received an already-validated path with no check of its own).

Moves the containment check (now shared as verifyWithinDestDir) to sit
immediately before each sink, including inside extractZipEntry, which had no
guard of its own before this change. Defense-in-depth regardless of whether it
satisfies CodeQL's specific analysis: extractZipEntry no longer blindly trusts
that its caller validated the path.

Addresses CodeQL alert #5230.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@github-actions github-actions Bot added size/m Medium size PR and removed size/s Small size PR labels Aug 4, 2026
Per CodeRabbit review on PR #2864: the git-root base_path regression test
only exercised --config (AtmosConfigFilesFromArg) with an empty base_path.
Converts it to table-driven cases covering --config-path
(AtmosConfigDirsFromArg) and base_path: "." as well, since
applyGitRootBasePath treats both spellings as unset and either CLI input
can carry that config.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@osterman

Copy link
Copy Markdown
Member Author

Re the "Out of Scope Changes" warning on the fast-uri bump: that's expected in this repo's workflow rather than an oversight. Pushing to this branch triggered GitHub's Dependabot/CodeQL alerts, which this repo's security-remediate automation handles by committing fixes directly onto whatever branch is already open (deliberately, to avoid a new PR per alert). It's isolated in its own commit for a clean history and addresses Dependabot alert #262 (fast-uri host-confusion vuln, high severity) — separate from the #2863 config fix, but intentionally on this branch rather than a new one.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Aug 4, 2026
The previous attempt (guarding each sink with a check on the *derived*
destination path) didn't satisfy CodeQL's PR check -- the CodeQL run on
PR #2864 still flagged the same extractZipFile loop after that commit.

CodeQL's own remediation text for go/zipslip documents the recognized
sanitizer as a direct `strings.Contains(name, "..")` check on the raw,
tainted archive entry name itself, not a check on a value derived from it
(sanitizeZipPath's per-component split-and-compare, or a filepath.Rel-based
containment check on the computed destPath, apparently aren't recognized
by the query's dataflow model). Add that exact guard on f.Name as the
first thing done with each entry, before any derived value is computed.

Addresses CodeQL alert #5230 / PR #2864 CodeQL check failure.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@codecov

codecov Bot commented Aug 4, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.00000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.62%. Comparing base (814fbdd) to head (7883803).

Files with missing lines Patch % Lines
pkg/toolchain/pr_artifact.go 76.47% 2 Missing and 2 partials ⚠️

❌ Your patch check has failed because the patch coverage (80.00%) is below the target coverage (85.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2864   +/-   ##
=======================================
  Coverage   82.62%   82.62%           
=======================================
  Files        1860     1860           
  Lines      180339   180353   +14     
=======================================
+ Hits       149006   149024   +18     
+ Misses      23449    23448    -1     
+ Partials     7884     7881    -3     
Flag Coverage Δ
unittests 82.62% <80.00%> (+<0.01%) ⬆️

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

Files with missing lines Coverage Δ
pkg/config/git_root.go 92.10% <100.00%> (+7.89%) ⬆️
pkg/config/load_config_args.go 92.74% <100.00%> (+0.11%) ⬆️
pkg/toolchain/pr_artifact.go 68.88% <76.47%> (+2.22%) ⬆️

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

…ge gap

Adds tests for the new CodeQL go/zipslip defense-in-depth guards (raw ".."
substring check, verifyWithinDestDir, and the extractZipEntry sink guard),
plus real filesystem fault-injection tests for parent-dir/file creation
failures. The two duplicate containment checks inline in extractZipFile's
loop remain uncovered — they're logically unreachable via black-box testing
since sanitizeZipPath already guarantees the same invariant before either
call site runs.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
coderabbitai[bot]
coderabbitai Bot previously approved these changes Aug 4, 2026
Introduces a gitRootResolver seam so tests can force ProcessTagGitRoot to
fail, since its own default-value fallback otherwise swallows every
underlying git-detection error and made this branch unreachable via
black-box testing. Closes the remaining Codecov patch-coverage gap on
load_config_args.go from PR #2864 by verifying the documented contract:
a git-root resolution failure is logged and does not fail config loading.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

@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

🧹 Nitpick comments (1)
pkg/config/load_config_args_test.go (1)

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

Use the repository error contract for the injected failure.

Line 4 and Lines 211-213 create a dynamic error with errors.New. The repository rule requires static errors from errors/errors.go and prohibits dynamic errors. Replace this with the matching sentinel, or confirm and document a test-only exception if no suitable sentinel exists.

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

Also applies to: 211-213

🤖 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 `@pkg/config/load_config_args_test.go` at line 4, Replace the dynamic
errors.New usage in the load-config argument tests, including the injected
failure setup around the affected test case, with the matching sentinel from
errors/errors.go. If no suitable repository sentinel exists, use the
project-approved test-only exception and document that exception rather than
introducing a new dynamic error.

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.

Inline comments:
In `@pkg/config/load_config_args_test.go`:
- Around line 211-213: Update the tests around loadConfigFromCLIArgs to track
invocation of the injected gitRootResolver with a called flag, set it inside the
resolver, and assert it after loading. Apply the same verification to the
additional test case covering the non-fatal git root detection error path.

---

Nitpick comments:
In `@pkg/config/load_config_args_test.go`:
- Line 4: Replace the dynamic errors.New usage in the load-config argument
tests, including the injected failure setup around the affected test case, with
the matching sentinel from errors/errors.go. If no suitable repository sentinel
exists, use the project-approved test-only exception and document that exception
rather than introducing a new dynamic error.
🪄 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: f7a741b3-42e0-4b2c-b3c8-04aaf565b655

📥 Commits

Reviewing files that changed from the base of the PR and between 4654e22 and 9196dfa.

📒 Files selected for processing (2)
  • pkg/config/git_root.go
  • pkg/config/load_config_args_test.go

Comment thread pkg/config/load_config_args_test.go Resolved
Addresses CodeRabbit review on PR #2864: the BasePath-empty assertion in
TestLoadConfigFromCLIArgs_GitRootBasePathErrorIsNonFatal could pass even if
gitRootResolver were never called, so it didn't actually prove the
non-fatal error path was exercised. Track invocation with a resolverCalled
flag and assert it.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@aknysh
Andriy Knysh (aknysh) merged commit 5c24ea2 into main Aug 4, 2026
84 of 85 checks passed
@aknysh
Andriy Knysh (aknysh) deleted the osterman/fix-issue-2863 branch August 4, 2026 23:53
@atmos-pro

atmos-pro Bot commented Aug 4, 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 commented Aug 5, 2026

Copy link
Copy Markdown

These changes were released in v1.225.0-rc.7.

zack-is-cool pushed a commit to zack-is-cool/atmos that referenced this pull request Aug 10, 2026
…rges (cloudposse#2875)

* fix(config): honor --config across internal reloads and multi-file array merges

Internal call sites that re-invoke InitCliConfig(schema.ConfigAndStacksInfo{}, false)
mid-command no longer silently discard --config/--config-path/--base-path, fixing
`atmos --config <file> terraform plan/test` falling back to plain auto-discovery
(closes cloudposse#2868). A second --config file with a conflicting array-typed value (e.g.
stacks.included_paths) no longer aborts stack discovery for entries that still
match, and `atmos config get` now reports the effective, fully-merged configuration
instead of a stale single-file value (closes cloudposse#2867).

Also precomputes VendorDirAbsolutePath/WorkflowsDirAbsolutePath (same base_path
resolution fix as cloudposse#2864) so vendor/workflow path joins don't re-derive a possibly
still-relative BasePath.

* fix: stop leaking absolute paths in workflow/vendor messages, split CliConfigPath for profiles

CI (linux/macos/windows) failed because getWorkflowsDirToUse/getVendorDirToUse
made the "Vendoring from" log message and the invalid/missing workflow manifest
error messages show a full, environment-length-dependent absolute path instead
of the previous cwd-relative one. That broke word-wrapped golden snapshots and
literal-pattern test assertions differently on every runner. Reuse the existing
displayPath() helper (validate_schema.go) so these messages stay short and
machine-independent again, while the underlying file resolution stays absolute
and correct.

Also addresses CodeRabbit findings on PR cloudposse#2875:
- discoverProfileLocations treated CliConfigPath's ";"-joined multi-directory
  form (from connectPaths, reachable now that --config flows into profile
  loading) as one directory, producing paths like "dirA;dirB;/.atmos/profiles"
  that could never exist. Split and search each contributor directory.
- Wrap the new Vendor/Workflows filepath.Abs failures with the existing
  absPathOrError/ErrPathResolution helper instead of returning a raw error.
- getWorkflowsDirToUse/getVendorDirToUse's fallback join now uses the
  absolute-aware u.JoinPath instead of filepath.Join.
- Reset viper and restore ATMOS_PROFILE around two tests that mutated global
  state without cleanup; fixed a doc comment that named the wrong test function.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* fix(config): fix 8 DX bugs found field-testing the --config/--profile precedence changes

A field-test pass against this branch's config-loading changes (multi-file --config
merging, profile precedence, config get/set) found 8 real, live-reproduced issues and
fixes them all, each with a failing test committed first:

- config set/delete/format silently edited only the FIRST --config file while config
  get reported the fully-merged value -- a false-success bug whenever a later file also
  set the same key. Now refuses ambiguous multi-file --config with a clear error
  (pkg/config/config_edit.go: new ErrAmbiguousConfigFile/ResolveConfigOverride, shared
  by cmd/config/operations.go and the duplicate in pkg/mcp/config/config.go).
- ATMOS_CONFIG/ATMOS_CONFIG_PATH with multiple comma-separated values worked for some
  commands (via pkg/config's own os.Args/env fallback) but broke ~40 others reading
  these flags through pkg/flags' Viper-based ParseGlobalFlags, which splits env-sourced
  values on whitespace, not commas. Fixed once at that shared choke point by exporting
  the existing --profile fix (parseViperProfilesFromEnv -> cfg.FixViperEnvStringSliceQuirk)
  and applying it there too.
- profiles.base_path declared in a non-first --config file resolved against the FIRST
  file's directory regardless of which file actually declared it, silently failing to
  find profiles that exist. Added per-file directory tracking (mirroring the existing
  base_path tracking in mergeFiles) threaded through to discoverProfileLocations.
- Vendor/workflow error messages (ErrEmptySources, ErrMissingVendorConfigDefinition,
  ErrDuplicateComponents, ErrComponentNotDefined, ErrNoComponentsWithTags, and others)
  still leaked absolute paths right next to the "Vendoring from" line already fixed in
  the prior commit -- a half-fixed pattern. Wrapped 13 sites in displayPath(), plus
  fixed a copy/paste bug in one workflow directory-read error that showed the raw
  unresolved config value instead of the path actually searched.
- displayPath() itself was silently defeated whenever the working directory was reached
  through a symlink (e.g. macOS's /tmp), because os.Getwd() preserves the logical $PWD
  path while git-root-discovery-resolved config paths are physical. Fixed with a
  two-attempt comparison (raw first, then both sides resolved via the directory, since
  the target file often doesn't exist yet).
- --config-path always wins over --config regardless of CLI argument order (undocumented,
  now documented, not code-changed -- effort didn't justify a fix for this ordering nuance).
- Documented the previously-undocumented ATMOS_CONFIG/ATMOS_CONFIG_PATH env vars and
  fixed --config's flag-type description on config-set/delete/format.mdx (all three
  incorrectly said "string" instead of "string slice").

Also updates the field-test skill to default to testing the current branch's diff
against its base branch when no explicit target is given, instead of asking.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* fix: address CodeRabbit review + close patch coverage gap on PR cloudposse#2875

CodeRabbit findings on the previous commit, verified and fixed:

- displayPath()'s relPath() treated any path whose relative form merely started
  with the substring ".." as escaping cwd, so an in-directory file literally
  named e.g. "..vendor.yaml" would incorrectly leak its absolute path. Now
  checks for ".." as a complete path segment, with a regression test.
- field-test skill: fixed the branch-targeting algorithm to resolve the actual
  PR base (gh pr view --json baseRefName) instead of the upstream tracking
  branch, which for a pushed feature branch produces an empty diff against
  itself; also now inspects staged/unstaged/untracked changes, not just
  committed history. Fixed the Phase 1 guidance that could be read as "skip
  internal/exec/" when the branch's diff actually touches it.
- configuration.mdx: split the flags/env-var precedence entries and stated
  explicitly that a flag always wins over its env var equivalent.
- vendor_utils_test.go: the "ErrEmptySources" test case actually exercised
  ErrMissingVendorConfigDefinition (same empty Sources+Imports triggers the
  earlier guard first) -- verified ErrEmptySources is structurally unreachable
  via ExecuteAtmosVendorInternal's public path given processVendorImports'
  per-level non-empty-content invariant, documented why, and removed the
  duplicate/misleading case rather than leave it mislabeled.
- The load_profile_test.go missing-period finding was already resolved (the
  comment reads as one grammatically complete, period-terminated sentence
  spanning two lines) and the patch-scoped lint gate already passes at 0
  issues, so left as-is.

Also closes the Codecov patch-coverage gate (83.33% -> ~94%, threshold 85%)
with real tests for the newly-added code, not coverage theater:

- cmd/config/operations.go: config get's InitCliConfig failure path (a
  malformed --config file).
- pkg/config/config_edit.go: ResolveConfigOverride's three branches directly.
- pkg/config/load.go / load_config_args.go: declaresProfilesBasePath's
  branches (malformed YAML, non-mapping profiles, mapping without base_path)
  via a direct table test.
- pkg/config/profiles.go: splitCliConfigPath's separators-only-no-content edge.
- pkg/config/utils.go: a genuine (non-ErrFailedToFindImport) glob syntax error
  in FindAllStackConfigsInPaths[ForStack], previously untested because the
  only existing test used the "matched nothing" tolerated case.
- internal/exec/vendor_utils.go: getVendorDirToUse/resolveVendorConfigFilePath
  directly, plus ErrDuplicateImport in processVendorImports.

Remaining gaps were investigated and left deliberately uncovered, each for a
stated reason rather than silently: two filepath.Abs error branches in
AtmosConfigAbsolutePaths (config.go) are unreachable because atmosBasePathAbs
is already guaranteed absolute by that point in the function (same as six
untested sibling branches above them predating this PR); a handful of
load.go/load_config_args.go lines are pre-existing code that only appear as
"added" because wrapping the old flow in a new if/else shifted their
indentation; and two permission-denied-style branches (vendor_utils.go,
workflow_utils.go) are the same class of cross-platform-fragile os.Chmod
scenario this repo already accepts as untested elsewhere
(TestReadWorkDirConfig_GetwdError).

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* fix: address CodeRabbit follow-up review on PR cloudposse#2875

Verified against current code, two real findings fixed and one skipped as
mechanically inapplicable:

- field-test skill: the branch-diff inspection was still incomplete --
  `--stat` alone never shows diff content, and untracked files never appear
  in `git diff HEAD` or a `--stat` summary at all, only their bare paths via
  `git status --porcelain`. Now reads the full `git diff <base>...HEAD`
  content and explicitly enumerates + reads untracked files via
  `git ls-files --others --exclude-standard`, so a brand-new implementation
  file can't go completely unread.
- vendor_utils_test.go: TestResolveVendorConfigFilePath_CheckGlobalConfig's
  "absolute Vendor.BasePath" subtest used a hardcoded "/abs/vendor" string
  literal, which filepath.IsAbs only treats as absolute on POSIX -- on
  Windows it would take the wrong branch (no drive letter/UNC prefix) and
  fail. Switched to an OS-native absolute path built from t.TempDir().
- Skipped: "create cmd.NewTestKit(t) before invoking configGetCmd.RunE" in
  cmd/config/operations_test.go. Verified this is not applicable: NewTestKit
  is declared in cmd/testkit_test.go (package cmd, a _test.go file, so not
  importable cross-package at all), and cmd/config could not import package
  cmd regardless -- cmd/root.go already imports cmd/config, so the reverse
  import would be a circular dependency and fail to build. The test already
  follows this same file's established isolation pattern (viper.Reset() +
  os.Args save/restore via t.Cleanup) for the state it actually depends on.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* fix: verify base ref resolves before diffing in field-test skill

CodeRabbit review on PR cloudposse#2875: the branch-name resolved via `gh pr view
--json baseRefName` / `gh repo view --json defaultBranchRef` was never
checked against what's actually available in the current checkout before
being handed to `git diff <base>...HEAD`. A shallow clone, detached HEAD, or
worktree with a narrow fetch refspec can know a branch's NAME without having
its commits, so the skill could silently attempt (and fail) a diff against
an unresolvable ref instead of falling back or asking.

Added an explicit verification step: try `origin/<resolved-name>`,
`<resolved-name>`, `origin/main`, `main` in order via
`git rev-parse --verify --quiet <candidate>^{commit}`, take the first that
resolves, and stop to ask the user only if none do -- rather than running
the diff against an unverified ref and surfacing a raw git error.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* chore: trigger CI re-run

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* fix(config): resolve base_path/profiles.base_path correctly with multi-source --config/--config-path

A field-test pass on the --config/--profile precedence branch found that connectPaths joins
every --config file/--config-path directory into a ";"-delimited CliConfigPath string once 2+
sources are given. Only profile discovery was taught to split that string; base_path resolution
still joined a relative value directly against it, producing a nonexistent path -- silently
breaking stack/component/vendor/workflow discovery ("No stacks found" with no error, or a
misleading "not inside a git repository" error even though the config loaded correctly).

- Add AtmosConfiguration.BasePathConfigDir, tracking whichever --config/--config-path source
  declared base_path (falling back to the first source), and anchor resolveAbsolutePath against
  it instead of the raw multi-directory CliConfigPath string.
- Extend mergeConfigFromDirectories to track profiles.base_path declarations the same way
  mergeFiles already does, so it's honored for --config-path directories, not just --config files.
- Backtick-wrap the glob path list in ErrNoStackManifestsFound so the markdown error renderer
  doesn't misinterpret "**" wildcards as emphasis and corrupt the rendered output.
- A bare (non-dot-prefixed) hook working_directory now anchors to the component directory
  instead of silently falling through to CWD-relative exec.Cmd.Dir behavior, consistent with the
  existing component-anchored default for an empty working_directory.

Updates docs/prd/base-path-resolution-semantics.md, atmos-profiles.md, and custom-hooks.md to
document the multi-source anchoring rule and the hook working_directory anchoring rule.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* fix: bump js-yaml/mermaid (security) + normalize pre-existing EditorConfig indentation

Security (Dependabot cloudposse#263-cloudposse#269, all transitive npm deps in website/, pinned via
pnpm.overrides, none requiring a major bump so none blocked by dependabot.yml's
semver-major ignore policy):
- js-yaml 3.15.0 -> 3.15.1, 4.3.0 -> 4.3.1 (GHSA-5p4m-2wfm-xmqj, high): quadratic
  CPU consumption in !!omap resolution
- mermaid 11.16.0 -> 11.16.1 (5 alerts)
No open CodeQL alerts at time of remediation. Verified with a full `pnpm run
build` in website/ -- succeeds with only pre-existing, unrelated warnings.
NOTICE is unaffected (tracks Go module dependencies only).

EditorConfig (CI failure fix): CI's "Validation (affected)" and "Run pre-commit
hooks" jobs validate every file touched on the branch in full, not just the
changed lines. Editing docs/prd/atmos-profiles.md and
docs/prd/base-path-resolution-semantics.md in an earlier commit surfaced 150
pre-existing "Wrong amount of left-padding spaces (want multiple of 2)"
violations elsewhere in those files -- long-standing 3/5/7-space list/pseudocode
indentation never previously caught because neither file had been touched by a
PR before. Normalized every odd-indented line to the next even width (add 1
space), preserving nesting structure.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* fix: address CodeRabbit review on PR cloudposse#2875

- getWorkflowsDirToUse/getVendorDirToUse: use getBasePathToUse (not raw
  atmosConfig.BasePath) in their fallback branches, consistent with every
  other BasePath-anchored resolution in internal/exec.
- Dedupe configGetTestStreams/configSchemaTestStreams into one shared
  configTestStreams/initConfigTestWriter helper in cmd/config.
- Expand AtmosConfigAbsolutePaths test coverage: absolute nested
  Vendor/Workflows.BasePath pass through unchanged, empty nested paths
  default to the base path itself.
- Assert stage 2/3 intermediate values in the array-field-merge test instead
  of only logging them, so a regression at those stages fails loudly.
- Extract resolveStackGlobMatches to share glob-pattern resolution and error
  handling between FindAllStackConfigsInPathsForStack and
  FindAllStackConfigsInPaths (previously duplicated verbatim).
- field-test skill: stop falling back to origin/main/main when a PR's actual
  base (e.g. develop) is known but unresolved locally -- that silently
  diffed against the wrong history. main is now a legitimate fallback only
  in the genuine no-PR case; a known non-default base that doesn't resolve
  now stops and asks instead.
- atmos-profiles.md: replace a duplicate, conflicting "Configuration loading
  chain" description with a reference to FR3.1 (the authoritative order),
  which also states that --config/--config-path bypass later discovery.

Verified the rest of the review (ErrEmptySources unreachability, several
already-applied fixes, and one nitpick -- retiring loadConfigFromCLIArgs --
deferred as disproportionate to its stated cleanup value) and left them
unchanged; see prior conversation turn for the itemized reasoning.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* fix(config): preserve genuine glob errors from every pattern, not just patterns[0]

resolveStackGlobMatches discarded every generated pattern's own error inside
the loop and, once no matches were found across all of them, only ever
retried patterns[0] to decide whether a genuine error had occurred. Since
GetGlobMatches always errors (wrapping ErrFailedToFindImport) on zero
matches, a genuine error (bad glob syntax, permission denied) from any
pattern after the first was silently discarded -- discovery could return no
matches or ErrNoStackManifestsFound instead of the real error.

Check each pattern's error inline: skip ErrFailedToFindImport (expected,
valid-but-empty), return every other error immediately with that pattern
(not a hardcoded patterns[0]) in its context. Removes the now-unnecessary
post-loop retry.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

---------

Co-authored-by: Claude Sonnet 5 <[email protected]>
Co-authored-by: Andriy Knysh <[email protected]>

This branch was successfully deployed

1 active deployment
preview — 78838037 Deployed Aug 4, 2026 by github-actions[bot]
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.

--config with multiple files skips base_path resolution entirely, breaking atmos terraform test

2 participants