Skip to content

fix Test.toml ledger paths#4530

Merged
jamie-osec merged 1 commit into
otter-sec:masterfrom
Monti-27:fix-test-ledger
May 27, 2026
Merged

fix Test.toml ledger paths#4530
jamie-osec merged 1 commit into
otter-sec:masterfrom
Monti-27:fix-test-ledger

Conversation

@Monti-27
Copy link
Copy Markdown
Contributor

Fixes #4529

Test.toml ledger paths were canonicalized while parsing, so missing output dirs failed early and existing dirs became absolute.

Keep ledger paths relative and only canonicalize validator inputs that Anchor reads.

Tests:

  • cargo test -p anchor-cli --lib test_toml_keeps_ledger_path_relative
  • cargo test -p anchor-cli --lib test_toml_resolves_account_dir_relative_to_file
  • cargo +nightly fmt --check
  • cargo clippy -p anchor-cli --lib -- -D warnings

@vercel
Copy link
Copy Markdown

vercel Bot commented May 13, 2026

@Monti-27 is attempting to deploy a commit to the Solana Foundation Team on Vercel.

A member of the Team first needs to authorize it.

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 13, 2026

Greptile Summary

This PR removes the canonicalize_filepath_from_origin call on the ledger path inside _TestToml::from_path, fixing a crash when the ledger directory doesn't yet exist at parse time and an incorrect absolute-path conversion that conflicted with the downstream test_validator_file_paths check requiring relative paths.

  • Root cause fixed: fs::canonicalize requires the path to exist on disk, so any non-existent ledger directory caused an early error during TOML parsing rather than being created later by the CLI.
  • Alignment with existing guard: test_validator_file_paths in lib.rs already enforces that validator.ledger is relative (calls process::exit(1) for absolute paths), so canonicalizing it to an absolute path was actively harmful.
  • Tests added: Two new tests cover the non-existent-directory and pre-existing-directory cases, confirming the raw relative path is preserved through parsing.

Confidence Score: 5/5

Safe to merge — the change is a three-line removal that corrects a mis-applied canonicalization, and the new tests confirm the fix for both the non-existent and pre-existing directory cases.

The deletion removes the only code path that called fs::canonicalize on the ledger field, which is exactly what broke callers when the ledger directory hadn't been created yet and also produced absolute paths that the downstream relative-path guard would reject. All other validator inputs (accounts, account_dir, genesis programs) continue to be canonicalized as before. The added tests directly exercise both failure modes from the original bug report.

No files require special attention.

Important Files Changed

Filename Overview
cli/src/config.rs Removes incorrect canonicalization of the validator ledger path in _TestToml::from_path; adds two unit tests verifying relative paths are preserved regardless of whether the ledger directory exists.

Reviews (1): Last reviewed commit: "fix Test.toml ledger paths" | Re-trigger Greptile

@Monti-27
Copy link
Copy Markdown
Contributor Author

@jamie-osec your views on this

@jamie-osec jamie-osec merged commit c836c1f into otter-sec:master May 27, 2026
54 of 62 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test.toml ledger paths are canonicalized too early

2 participants