Skip to content

Conversation

@josecelano
Copy link
Member

Fixes #225

Summary

This PR implements validation to ensure SSH key paths are absolute during create environment command, preventing failures later during configure and other commands.

Changes

  • Validation Logic: Added is_absolute() checks for both private and public SSH key paths in SshCredentialsConfig::new()
  • Error Handling: Added two new error variants:
    • RelativePrivateKeyPath - for relative private key paths
    • RelativePublicKeyPath - for relative public key paths
  • Error Messages: Comprehensive help text with:
    • Clear explanation of the problem
    • realpath command examples for fixing
    • Rationale for why absolute paths are required
  • Tests: Added 5 new unit tests demonstrating validation behavior
  • Test Updates: Updated 23 existing tests to use absolute paths via CARGO_MANIFEST_DIR
  • Doc Examples: Marked 6 doc examples as no_run to prevent execution

Validation

✅ All 1429 unit tests passing
✅ All 315 doctests passing
✅ All pre-commit checks passing
✅ Manual E2E testing confirmed:

  • Relative private key path → rejected with clear error
  • Relative public key path → rejected with clear error
  • Absolute paths → accepted and environment created successfully

Example Error Output

❌ Create command failed: Configuration validation failed: SSH private key path must be absolute: "fixtures/testing_rsa"

SSH private key path must be absolute.

Fix:
1. Convert relative path to absolute path:

Use the `realpath` command to get the absolute path:

realpath <your-relative-path>

Example:
- Current (relative): fixtures/testing_rsa
- Command: realpath fixtures/testing_rsa
- Result: /home/user/project/fixtures/testing_rsa

2. Update your configuration file with the absolute path

Benefits

  • Fail Fast: Errors caught immediately during config parsing, before any infrastructure operations
  • Clear Guidance: Users get actionable error messages with specific fix instructions
  • Prevents Later Failures: Eliminates cryptic SSH failures during configure and subsequent commands
  • Multi-command Safety: Ensures paths work correctly across different working directories

@josecelano josecelano self-assigned this Dec 12, 2025
@josecelano
Copy link
Member Author

josecelano commented Dec 12, 2025

ACK 0ded857

@josecelano josecelano merged commit 4810592 into main Dec 12, 2025
34 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.

Validate SSH Key Paths Must Be Absolute

2 participants