Skip to content

Add --storage-class CLI flag validation logic #1732

@DavidCastroSanchez

Description

@DavidCastroSanchez

Tell us more about this new feature.

Summary

Add CLI-level validation for the --storage-class flag to ensure only valid S3 storage classes are accepted at mount time, providing immediate feedback to users before attempting to mount.

Motivation

Currently, invalid storage class values may not be caught until an upload operation fails. By validating storage classes at CLI parsing time using a strongly-typed enum, users receive immediate, clear error messages when specifying an invalid value.

Example (misspelled INTELLIGENT_TIERING with one L):

Current behavior:

# mount-s3 <bucket_name> mounted-s3 --storage-class INTELIGENT_TIERING
bucket <bucket_name> is mounted at mounted-s3
# echo "Hello from Mountpoint!" > test.txt
bash: echo: write error: Input/output error

Expected behavior:

# mount-s3 <bucket_name> mounted-s3 --storage-class INTELIGENT_TIERING
error: invalid value 'INTELIGENT_TIERING' for '--storage-class <STORAGE_CLASS>'
  [possible values: STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, OUTPOSTS, GLACIER_IR, SNOW, EXPRESS_ONEZONE]

  tip: a similar value exists: 'INTELLIGENT_TIERING'

For more information, try '--help'.

Proposed Implementation

Introduce a StorageClass enum implementing clap's ValueEnum trait that validates input against all valid S3 storage classes:

  • STANDARD
  • REDUCED_REDUNDANCY
  • STANDARD_IA
  • ONEZONE_IA
  • INTELLIGENT_TIERING
  • GLACIER
  • DEEP_ARCHIVE
  • OUTPOSTS
  • GLACIER_IR
  • SNOW
  • EXPRESS_ONEZONE

The validation should:

  • Accept only uppercase values (matching S3 API requirements)
  • Reject empty strings, lowercase and mixed case
  • Provide helpful error messages listing valid options and similar values when possible

Additional Context

  • Reference: S3 PutObject StorageClass documentation
  • Note: EXPRESS_ONEZONE is only valid for directory buckets (further bucket-type validation may be a separate enhancement)
  • Note: FSX_OPENZFS and FSX_ONTAP options are not included

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions