Skip to content

fix(connectivity): vpc_peering create sends wrong JSON keys (awsRegion vs region) #75

@joshrotenberg

Description

@joshrotenberg

Summary

VpcPeeringHandler::create_vpc_peering (and the legacy ConnectivityHandler::create_vpc_peering) sends a request body whose JSON keys do not match the Redis Cloud spec. The API will reject or silently ignore fields.

Expected behavior

Per spec, POST /subscriptions/{subscriptionId}/peerings accepts a oneOf of AWS- or GCP-shaped bodies with the following keys:

  • AWS: region, awsAccountId, vpcId, vpcCidr, vpcCidrs
  • GCP: vpcProjectUid, vpcNetworkName

(Plus the provider discriminator.)

Actual behavior

src/connectivity/vpc_peering.rs:10-46 defines a single all-Optional struct that collapses both providers and uses the wrong field names:

```rust
pub struct VpcPeeringCreateRequest {
pub provider: String,
pub aws_region: Option, // → awsRegion (spec wants 'region')
pub aws_account_id: Option, // OK after camelCase
pub vpc_id: Option, // OK
pub vpc_cidr: Option, // OK
pub vpc_cidrs: Option<Vec>, // OK
pub gcp_project_id: Option, // → gcpProjectId (spec wants 'vpcProjectUid')
pub network_name: Option, // → networkName (spec wants 'vpcNetworkName')
}
```

With #[serde(rename_all = "camelCase")], the wire keys become the wrong names listed above.

Impact

VPC peering creation through the typed handler is broken on both AWS and GCP:

  • AWS: awsRegion is unknown to the API; region is missing → 400 from server.
  • GCP: gcpProjectId and networkName are unknown; vpcProjectUid and vpcNetworkName are missing → 400.

Also, the collapsed struct lets callers send mixed AWS+GCP fields the spec rejects.

Relevant code

  • src/connectivity/vpc_peering.rs:10-46
  • Spec: tests/fixtures/cloud_openapi.jsonpeerings POST → oneOf body schemas

Suggested fix

Either:

  1. Add #[serde(rename = ...)] per field for the wire names that need it (region, vpcProjectUid, vpcNetworkName).
  2. Split into AwsVpcPeeringCreateRequest / GcpVpcPeeringCreateRequest matching the spec's oneOf. Provide enum VpcPeeringCreateRequest { Aws(...), Gcp(...) } with #[serde(untagged)] or provider-discriminated.

Option 2 is preferred — closes the cross-provider field-mixing hole and makes intent explicit at the call site.

Acceptance criteria

  • AWS create body serializes with region, awsAccountId, vpcId, vpcCidr/vpcCidrs, provider: "aws"
  • GCP create body serializes with vpcProjectUid, vpcNetworkName, provider: "gcp"
  • AWS+GCP fields cannot be mixed in one call (compile-time)
  • Mock tests assert the exact outbound JSON keys for both providers
  • Live validation against a Cloud account if available

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions