Skip to content

Conversation

@jmgilman
Copy link
Contributor

Summary

  • Add ValidateFiles(paths ...string) ([]string, error) method to Blob for bulk file validation
  • Add ValidationError type with Path and Reason fields for detailed error reporting
  • Re-export ValidationError from top-level package

This enables fail-fast validation for commands like cat that need to verify all files exist before starting output.

Key features

  • Normalizes paths internally (accepts /file.txt, file.txt/, etc.)
  • Returns normalized paths suitable for use with Open, ReadFile, etc.
  • Reports specific error reasons: "not found", "is a directory", "not a regular file", "invalid path"
  • Preserves original path in error messages for user-friendly output

Example usage

normalized, err := archive.ValidateFiles("/etc/hosts", "config.json")
if err != nil {
    var valErr *blob.ValidationError
    if errors.As(err, &valErr) {
        fmt.Printf("%s: %s\n", valErr.Reason, valErr.Path)
    }
    return err
}

// Use normalized paths with Open/ReadFile
for _, path := range normalized {
    content, _ := archive.ReadFile(path)
    // ...
}

Test plan

  • Unit tests for all validation scenarios (valid files, not found, directories, invalid paths)
  • Test that returned normalized paths work with Open
  • just ci passes

🤖 Generated with Claude Code

Add ValidateFiles method to Blob that validates all paths exist and are
regular files before processing. This enables fail-fast validation for
commands that need to verify files before starting output.

The method returns normalized paths suitable for use with Open, ReadFile,
and other Blob methods, ensuring consistency between validation and
subsequent operations.

Also adds ValidationError type with Path and Reason fields for detailed
error reporting.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@cloudflare-workers-and-pages
Copy link

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
blob ab2dc71 Commit Preview URL

Branch Preview URL
Jan 23 2026, 06:13 AM

@jmgilman jmgilman merged commit 5eb137a into master Jan 23, 2026
10 checks passed
@jmgilman jmgilman deleted the feat/validate-files branch January 23, 2026 06:18
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.

2 participants