Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

empty Local secondary indices results in error when calling createTableWithIndices #6

Closed
1337jwilliams95 opened this issue Sep 14, 2022 · 3 comments

Comments

@1337jwilliams95
Copy link

When using createTableWithIndices to create a table with indices (global but not local) I get the following error
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tableInitializer': Invocation of init method failed; nested exception is software.amazon.awssdk.services.dynamodb.model.DynamoDbException: LSI list is empty/invalid (Service: DynamoDb, Status Code: 400, Request ID: 4c1beac5-c3cc-409e-89f9-778c1b2a27d0, Extended Request ID: null)

I believe this could be resolved like this below.

val builder = CreateTableEnhancedRequest.builder()
    globalIndices.takeIf { it.isNotEmpty() }?.apply { builder.globalSecondaryIndices(this) }
    localIndices.takeIf { it.isNotEmpty() }?.apply { builder.localSecondaryIndices(this) }
    val request = builder
        .build()

    createTable(request)

note: I wasn't able to reproduce my issue with your local tests

@oharaandrew314
Copy link
Owner

oharaandrew314 commented Sep 14, 2022 via email

@1337jwilliams95
Copy link
Author

Hey, thanks for the fast response! I tried creating a pr but it looks like I don't have the permissions. Those changes above worked for the repo test, and resolved my issue in my service!

@oharaandrew314
Copy link
Owner

Turns out this problem was already noticed and a fix suggested in aws/aws-sdk-java-v2#1771 (comment). I've integrated the fix and addressed another shortcoming with projections when creating tables in real DynamoDB.

The fix is now available on Jitpack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants