Skip to content

fix: validate duplicate package names and paths#78

Merged
BryanFRD merged 1 commit intomainfrom
fix/validate-duplicate-packages
Apr 8, 2026
Merged

fix: validate duplicate package names and paths#78
BryanFRD merged 1 commit intomainfrom
fix/validate-duplicate-packages

Conversation

@BryanFRD
Copy link
Copy Markdown
Contributor

@BryanFRD BryanFRD commented Apr 8, 2026

Summary

  • Add validation for duplicate packages[*].name values
  • Add validation for duplicate packages[*].path values
  • Add 2 tests

Closes #71

Copilot AI review requested due to automatic review settings April 8, 2026 15:02
@BryanFRD BryanFRD merged commit 5035c3b into main Apr 8, 2026
4 checks passed
@BryanFRD BryanFRD deleted the fix/validate-duplicate-packages branch April 8, 2026 15:04
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds fixture definition validation to prevent ambiguous/unsafe package configurations where multiple packages share the same name or path (which can lead to overwriting generated version.toml files).

Changes:

  • Add validation for duplicate packages[*].name values.
  • Add validation for duplicate packages[*].path values.
  • Add unit tests covering duplicate package names and paths.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +105 to +112
// Check for duplicate package paths
let mut pkg_paths: Vec<&str> = def.packages.iter().map(|p| p.path.as_str()).collect();
pkg_paths.sort();
for window in pkg_paths.windows(2) {
if window[0] == window[1] {
errors.push(format!("duplicate package path: '{}'", window[0]));
}
}
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

packages[*].path is used to create directories/files via output_dir.join(&pkg.path) in generate.rs, but validate_single doesn't validate package paths for absolute paths or .. traversal (unlike commits/hooks/config). This can write outside the output directory, and also allows semantically equivalent paths (e.g. "./", "", "a/.") to bypass the duplicate-path check and still overwrite the same version.toml. Consider (1) rejecting absolute/traversal components for package paths using the existing has_traversal helper, and (2) normalizing/cleaning paths before the duplicate-path comparison so logically identical paths are treated as duplicates.

Copilot uses AI. Check for mistakes.
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.

fix: validate duplicate package names and paths

2 participants