awslabs / aws-sdk-rust

AWS SDK for the Rust Programming Language
https://awslabs.github.io/aws-sdk-rust/
Apache License 2.0
2.91k stars 245 forks source link

Cannot Query tables with dynamodb sdk depending on how the table is named. #1120

Closed DotRed108 closed 2 months ago

DotRed108 commented 3 months ago

Describe the bug

DynamoDB tables cannot be queried if table has number at the beginning of the name or a hyphen/period anywhere in the name. Screenshot 2024-03-29 at 6 24 33 PM

Entries with X cannot be queried. Sdk will return service error.

Expected Behavior

All tables with valid names should be able to be queried.

Current Behavior

Querying tables where the name starts with a number or contains a hyphen/period causes the query to fail and return a service error.

Reproduction Steps

First create a table in dynamoDB using any method.

Run this code in a lambda function.

use lambda_http::{run, service_fn, tracing, Body, Error, Request, RequestExt, Response};
use aws_config::{self, BehaviorVersion, Region};
use aws_sdk_dynamodb::client as DDBClient;

const EXAMPLE_TABLE: &str = "018e8b50-7a46-7d26-9fc0-d0da4e8d9dfc-EXAMPLE";

async fn function_handler(event: Request) -> Result<Response<Body>, Error> {
    let config = aws_config::defaults(BehaviorVersion::latest()).region(Region::new("us-east-2")).load().await;
    let client = DDBClient::new(&config);

    let sql = format!("SELECT * FROM {}", EXAMPLE_TABLE);

    match client.execute_statement().statement(sql).send().await {
        Ok(cool) => println!("Thats cool {:?}", cool),
        Err(e) => println!("{e}"),
    }

    let message = format!("Hello World, this is an AWS Lambda HTTP request");

    let resp = Response::builder()
        .status(200)
        .header("content-type", "text/html")
        .body(message.into())
        .map_err(Box::new)?;
    Ok(resp)
}

#[tokio::main]
async fn main() -> Result<(), Error> {
    tracing::init_default_subscriber();

    run(service_fn(function_handler)).await
}

Possible Solution

No response

Additional Information/Context

Bug was found while using the cargo lambda watch command. In a lambda function.

Version

[dependencies]
aws-config = "1.1.9"
aws-sdk-dynamodb = "1.20.0"
lambda_http = "0.11.0"

tokio = { version = "1", features = ["macros"] }

Environment details (OS name and version, etc.)

MacOS Ventura Version 13.6.4

Logs

No response

ysaito1001 commented 2 months ago

Hi @DotRed108, if you do not use the Rust SDK, say if you use AWS CLI, can you query those offending tables successfully?

Sdk will return service error.

Could you share with us what error you are observing?

github-actions[bot] commented 2 months ago

Greetings! It looks like this issue hasn’t been active in longer than a week. We encourage you to check if this is still an issue in the latest release. Because it has been longer than a week since the last update on this, and in the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please feel free to provide a comment or add an upvote to prevent automatic closure, or if the issue is already closed, please feel free to open a new one.