Restore strict validation for user-input enums#104
Merged
Conversation
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>
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>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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>
- 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>
iskakaushik
approved these changes
Apr 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
FromStronflexible_string_enum!reject unknown values, soparse_enumcatches typos like--provider awssor--region us-east-99at the CLI layer before they reach the APIDeserializeimpl still accepts unknown values from API responses (forward-compatible)known_values()method to each flexible enum, and the error message lists all valid optionsFromStrrejection,known_values(), and confirming deserialization still accepts unknownsTest plan
cargo test— all 259 tests pass (8 new)cargo clippy— cleancargo run -- cloud service create --provider awssshould fail with a clear error listing valid providersCloses #101
🤖 Generated with Claude Code