awslabs / awslabs/aws-sdk-rust
VPC endpoint state value parsing is incorrect
- Dominant language
- Rust
- Stars
- 3.3k
- Forks
- 290
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 3
Description
### Describe the bug
[VPC endpoint state](https://docs.rs/aws-sdk-ec2/0.18.0/aws_sdk_ec2/model/enum.State.html) values when parsed from their text representation are incorrect. The reason is that code expect them to be in `PascalCase`, while in fact they are `camelCase`. As a result all the values are getting classified as `State::Unknown("xxx")`.
For example
`pendingAcceptance` is expected to be `PendingAcceptance`
`available` is expected to be `Available`
etc
### Expected Behavior
When running reproduction code below I expect the next output
```
Some(
PendingAcceptance,
),
Some(
Available
)
```
### Current Behavior
Instead every possible VPC endpoint state in `describe_vpc_endpoints()` is showed as `State::Unknown("text")`
```
Some(
Unknown(
"pendingAcceptance",
),
)
Some(
Unknown(
"available",
),
)
```
### Reproduction Steps
If you have at least one VPC endpoint
```
use aws_sdk_ec2 as ec2;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let shared_config = aws_config::load_from_env().await;
ec2::Client::new(&shared_config)
.describe_vpc_endpoints()
.send()
.await?
.vpc_endpoints
.unwrap_or_default()
.into_iter()
.for_each(|ep| println!("{:#?}", ep.state()));
Ok(())
}
```
### Possible Solution
```
diff --git a/sdk/ec2/src/model.rs b/sdk/ec2/src/model.rs
index 916c9ee62..30ba20e6a 100644
--- a/sdk/ec2/src/model.rs
+++ b/sdk/ec2/src/model.rs
@@ -68004,14 +68004,14 @@ pub enum State {
impl std::convert::From<&str> for State {
fn from(s: &str) -> Self {
match s {
- "Available" => State::Available,
- "Deleted" => State::Deleted,
- "Deleting" => State::Deleting,
- "Expired" => State::Expired,
- "Failed" => State::Failed,
- "Pending" => State::Pending,
- "PendingAcceptance" => State::PendingAcceptance,
- "Rejected" => State::Rejected,
+ "available" => State::Available,
+ "deleted" => State::Deleted,
+ "deleting" => State::Deleting,
+ "expired" => State::Expired,
+ "failed" => State::Failed,
+ "pending" => State::Pending,
+ "pendingAcceptance" => State::PendingAcceptance,
+ "rejected" => State::Rejected,
other => State::Unknown(other.to_owned()),
}
}
@@ -68027,28 +68027,28 @@ impl State {
/// Returns the `&str` value of the enum member.
pub fn as_str(&self) -> &str {
match self {
- State::Available => "Available",
- State::Deleted => "Deleted",
- State::Deleting => "Deleting",
- State::Expired => "Expired",
- State::Failed => "Failed",
- State::Pending => "Pending",
- State::PendingAcceptance => "PendingAcceptance",
- State::Rejected => "Rejected",
+ State::Available => "available",
+ State::Deleted => "deleted",
+ State::Deleting => "deleting",
+ State::Expired => "expired",
+ State::Failed => "failed",
+ State::Pending => "pending",
+ State::PendingAcceptance => "pendingAcceptance",
+ State::Rejected => "rejected",
State::Unknown(s) => s.as_ref(),
}
}
/// Returns all the `&str` values of the enum members.
pub fn values() -> &'static [&'static str] {
&[
- "Available",
- "Deleted",
- "Deleting",
- "Expired",
- "Failed",
- "Pending",
- "PendingAcceptance",
- "Rejected",
+ "available",
+ "deleted",
+ "deleting",
+ "expired",
+ "failed",
+ "pending",
+ "pendingAcceptance",
+ "rejected",
]
}
}
```
### Additional Information/Context
_No response_
### Version
```text
├── aws-config v0.48.0
│ ├── aws-http v0.48.0
│ │ ├── aws-smithy-http v0.48.0
│ │ │ ├── aws-smithy-types v0.48.0
│ │ ├── aws-smithy-types v0.48.0 (*)
│ │ ├── aws-types v0.48.0
│ │ │ ├── aws-smithy-async v0.48.0
│ │ │ ├── aws-smithy-client v0.48.0
│ │ │ │ ├── aws-smithy-async v0.48.0 (*)
│ │ │ │ ├── aws-smithy-http v0.48.0 (*)
│ │ │ │ ├── aws-smithy-http-tower v0.48.0
│ │ │ │ │ ├── aws-smithy-http v0.48.0 (*)
│ │ │ │ ├── aws-smithy-types v0.48.0 (*)
│ │ │ ├── aws-smithy-http v0.48.0 (*)
│ │ │ ├── aws-smithy-types v0.48.0 (*)
│ ├── aws-sdk-sso v0.18.0
│ │ ├── aws-endpoint v0.48.0
│ │ │ ├── aws-smithy-http v0.48.0 (*)
│ │ │ ├── aws-smithy-types v0.48.0 (*)
│ │ │ ├── aws-types v0.48.0 (*)
│ │ ├── aws-http v0.48.0 (*)
│ │ ├── aws-sig-auth v0.48.0
│ │ │ ├── aws-sigv4 v0.48.0
│ │ │ │ ├── aws-smithy-http v0.48.0 (*)
│ │ │ ├── aws-smithy-http v0.48.0 (*)
│ │ │ ├── aws-types v0.48.0 (*)
│ │ ├── aws-smithy-async v0.48.0 (*)
│ │ ├── aws-smithy-client v0.48.0 (*)
│ │ ├── aws-smithy-http v0.48.0 (*)
│ │ ├── aws-smithy-http-tower v0.48.0 (*)
│ │ ├── aws-smithy-json v0.48.0
│ │ │ └── aws-smithy-types v0.48.0 (*)
│ │ ├── aws-smithy-types v0.48.0 (*)
│ │ ├── aws-types v0.48.0 (*)
│ ├── aws-sdk-sts v0.18.0
│ │ ├── aws-endpoint v0.48.0 (*)
│ │ ├── aws-http v0.48.0 (*)
│ │ ├── aws-sig-auth v0.48.0 (*)
│ │ ├── aws-smithy-async v0.48.0 (*)
│ │ ├── aws-smithy-client v0.48.0 (*)
│ │ ├── aws-smithy-http v0.48.0 (*)
│ │ ├── aws-smithy-http-tower v0.48.0 (*)
│ │ ├── aws-smithy-query v0.48.0
│ │ │ ├── aws-smithy-types v0.48.0 (*)
│ │ ├── aws-smithy-types v0.48.0 (*)
│ │ ├── aws-smithy-xml v0.48.0
│ │ ├── aws-types v0.48.0 (*)
│ ├── aws-smithy-async v0.48.0 (*)
│ ├── aws-smithy-client v0.48.0 (*)
│ ├── aws-smithy-http v0.48.0 (*)
│ ├── aws-smithy-http-tower v0.48.0 (*)
│ ├── aws-smithy-json v0.48.0 (*)
│ ├── aws-smithy-types v0.48.0 (*)
│ ├── aws-types v0.48.0 (*)
├── aws-sdk-ec2 v0.18.0
│ ├── aws-endpoint v0.48.0 (*)
│ ├── aws-http v0.48.0 (*)
│ ├── aws-sig-auth v0.48.0 (*)
│ ├── aws-smithy-async v0.48.0 (*)
│ ├── aws-smithy-client v0.48.0 (*)
│ ├── aws-smithy-http v0.48.0 (*)
│ ├── aws-smithy-http-tower v0.48.0 (*)
│ ├── aws-smithy-query v0.48.0 (*)
│ ├── aws-smithy-types v0.48.0 (*)
│ ├── aws-smithy-xml v0.48.0 (*)
│ ├── aws-types v0.48.0 (*)
├── aws-types v0.48.0 (*)
```
```
### Environment details (OS name and version, etc.)
macOS Monterey
### Logs
_No response_
Contributor guide
Research direction
Start in sdk/ec2/src/model.rs at the State enum and inspect its From<&str>, as_str, and values implementations. Run the provided VPC endpoint reproduction or equivalent parsing checks, and verify that the documented camelCase values map to the corresponding State variants rather than State::Unknown.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, rust
- Domain
- api
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100