Skip to content

Restore strict validation for user-input enums#104

Merged
sdairs merged 5 commits intomainfrom
issue-101-strict-input-validation
Apr 14, 2026
Merged

Restore strict validation for user-input enums#104
sdairs merged 5 commits intomainfrom
issue-101-strict-input-validation

Conversation

@sdairs
Copy link
Copy Markdown
Collaborator

@sdairs sdairs commented Apr 10, 2026

Summary

  • Makes FromStr on flexible_string_enum! reject unknown values, so parse_enum catches typos like --provider awss or --region us-east-99 at the CLI layer before they reach the API
  • The custom Deserialize impl still accepts unknown values from API responses (forward-compatible)
  • Adds known_values() method to each flexible enum, and the error message lists all valid options
  • Adds 8 new tests covering strict FromStr rejection, known_values(), and confirming deserialization still accepts unknowns

Test plan

  • cargo test — all 259 tests pass (8 new)
  • cargo clippy — clean
  • Manual: cargo run -- cloud service create --provider awss should fail with a clear error listing valid providers

Closes #101

🤖 Generated with Claude Code

Make FromStr on flexible_string_enum! reject unknown values so that
parse_enum catches typos like --provider awss at the CLI layer, while
the custom Deserialize impl still accepts unknown API response values.
Also adds a known_values() method to each flexible enum.

Closes #101

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sdairs sdairs requested a review from iskakaushik as a code owner April 10, 2026 15:23
@sdairs sdairs temporarily deployed to cloud-integration April 10, 2026 15:23 — with GitHub Actions Inactive
Move build_create_service_request, build_update_service_request,
build_api_key_create_request, and build_api_key_update_request calls
ahead of resolve_org_id so that invalid enum values like --provider awss
fail with a local validation error instead of hitting the /organizations
API endpoint first.

Adds 6 regression tests that verify each build_* function rejects
invalid enum values without any network call.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sdairs sdairs temporarily deployed to cloud-integration April 10, 2026 17:01 — with GitHub Actions Inactive
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sdairs sdairs temporarily deployed to cloud-integration April 10, 2026 19:42 — with GitHub Actions Inactive
The Error::Cloud variant wraps both local validation failures and actual
API errors, so "Cloud API error" was misleading for input typos that
never reach the network.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sdairs sdairs temporarily deployed to cloud-integration April 10, 2026 20:18 — with GitHub Actions Inactive
- Remove "Cloud error:" prefix from Error::Cloud variant since the
  binary already prints "Error:" — avoids "Error: Cloud error: ..."
- Align string_enum! FromStr output to match flexible_string_enum!
  format (lists valid values instead of printing the type name)
- Drop redundant value from parse_enum wrapper since FromStr already
  includes it

Before: Error: Cloud API error: invalid provider 'awss': unknown value 'awss', expected one of: aws, gcp, azure
After:  Error: invalid provider: unknown value 'awss', expected one of: aws, gcp, azure

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sdairs sdairs temporarily deployed to cloud-integration April 10, 2026 20:27 — with GitHub Actions Inactive
@sdairs sdairs merged commit 59b600d into main Apr 14, 2026
1 check 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.

Restore strict validation for user-input enums (provider, region, tier)

2 participants