Repository navigation
Description
Overview
The validate command currently checks whether SSH key files exist on the filesystem. This is incorrect - the validate command should only perform syntactic validation (checking that paths are absolute), not runtime validation (checking that files exist).
Current Behavior:
- ✅ Correctly rejects relative paths:
fixtures/testing_rsa→ Error: "SSH private key path must be absolute" - ❌ Bug: Rejects absolute paths if files don't exist:
/home/user/.ssh/id_rsa→ Error: "SSH private key file not found"
Expected Behavior: The validate command should accept absolute paths without checking file existence. File existence validation should only happen in the create environment command.
Specification
See detailed specification: docs/issues/340-validate-ssh-key-file-existence.md
🏗️ Architecture Requirements
DDD Layer: Application
Module Path: src/application/command_handlers/validate/ or src/application/command_handlers/create/config/ssh_credentials_config.rs
Pattern: DTO validation / Command handler
Module Structure Requirements
- Follow DDD layer separation (validation may happen in DTO → Domain conversion)
- Respect dependency flow rules (Application → Domain)
- Use appropriate error types (see docs/contributing/error-handling.md)
Architectural Constraints
- Validation logic should be testable in isolation
- Error messages must be actionable and user-friendly (see docs/development-principles.md)
- No file I/O during validate command (syntactic validation only)
Anti-Patterns to Avoid
- ❌ Checking file existence in validate command (should only be in create environment)
- ❌ Generic error messages without actionable guidance
- ❌ Mixing syntactic and runtime validation concerns
Implementation Plan
Phase 1: Locate File Existence Check (15 minutes)
- Search codebase for file existence validation logic
- Identify where
SshCredentialschecks if files exist - Determine if check is in domain layer, application layer, or adapter layer
- Document current flow: validate command → ... → file existence check
Phase 2: Refactor to Skip File Check in Validate (45 minutes)
- Add parameter/flag to skip file existence check (e.g.,
validate_existence: bool) - Update
SshCredentials::new()or conversion method to accept flag - Validate command passes
validate_existence: false - Create environment command passes
validate_existence: true - Ensure absolute path validation still runs in both cases
Phase 3: Unit Tests (30 minutes)
- Add test:
it_should_accept_absolute_paths_without_checking_existence - Add test:
it_should_still_reject_relative_paths - Add test:
it_should_check_file_existence_when_flag_is_true(for create command) - Verify tests follow naming conventions from docs/contributing/testing/unit-testing.md
Phase 4: E2E Tests (30 minutes)
- Test using
bug-validation-valid-absolute-paths.json(should now pass) - Test using
bug-validation-invalid-relative-paths.json(should still fail) - Verify create environment command still checks file existence
- Update
tests/e2e/validate_command.rswith regression tests
Phase 5: Documentation (15 minutes)
- Update docs/user-guide/commands/validate.md to clarify validation scope
- Document that validate checks path format only, not file existence
- Add example showing this distinction
- Update error message examples if needed
Acceptance Criteria
Note for Contributors: These criteria define what the PR reviewer will check. Use this as your pre-review checklist before submitting the PR to minimize back-and-forth iterations.
Quality Checks:
- Pre-commit checks pass:
./scripts/pre-commit.sh
Task-Specific Criteria:
- ✅ Validate command accepts absolute SSH key paths without checking file existence
- ❌ Validate command still rejects relative SSH key paths with clear error
- ✅ Create environment command still checks if SSH key files exist
- Unit tests cover both validate (no file check) and create (with file check) scenarios
- E2E tests verify
bug-validation-valid-absolute-paths.jsonnow passes validation - E2E tests verify
bug-validation-invalid-relative-paths.jsonstill fails validation - Documentation clarifies validation scope (syntactic vs runtime checks)
Related
- Specification: docs/issues/340-validate-ssh-key-file-existence.md
Activity
docs: add issue specification for #340
fix: [#340] remove SSH key file existence validation from config parsing
Merge #341: Fix: Remove SSH key file existence validation from config…
chore: remove completed issue #340 documentation