awslabs / dynein

DynamoDB CLI written in Rust.
https://github.com/awslabs/dynein
Apache License 2.0
360 stars 37 forks source link

export command cause panic when table doesn't have items #152

Closed ryota-sakamoto closed 3 months ago

ryota-sakamoto commented 1 year ago

Description

If the table doesn't have items, export command cause panic due to truncate.

> cargo run -- scan
    Finished dev [unoptimized + debuginfo] target(s) in 0.28s
     Running `target/debug/dy scan`
No item to show in the table 'fuga'

> cargo run -- export --output-file export_test
    Finished dev [unoptimized + debuginfo] target(s) in 0.27s
     Running `target/debug/dy export --output-file export_test`
Specified output file already exists. Is it OK to truncate contents? yes
thread 'main' panicked at 'attempt to subtract with overflow', src/transfer.rs:461:20
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

We will need to use more simple way to concatenate output instead of putting comma manually.

https://github.com/awslabs/dynein/blob/bd470cf80394b8960314607c843f2a6c35ddf347/src/transfer.rs#L451-L465