Skip to content

DynamoDbMapper getItem not working by providing key as String #1577

@chung-yan-leung

Description

@chung-yan-leung

Describe the bug

Using getItem(partitionKey: PK) where the partitionKey is a String in the data class which generates the schema produces the following error:

kotlin.NotImplementedError: An operation is not implemented: not yet implemented
	at aws.sdk.kotlin.hll.dynamodbmapper.model.internal.TableImplKt$tableImpl$1.getItem(TableImpl.kt:38) ~[dynamodb-mapper-jvm-1.4.58-beta.jar:na]

Trying to use getItem { key = "a-string-key" } following the example on the blog, it said the type of the key required is the class which generates the schemas, instead of String.

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected behavior

  • Calling getItem() without any error.

  • The type of the key in getItem builder block should be the type of DynamoDbPartitionKey defined in the class.

Current behavior

  • Calling getItem() throws NotImplementedError

  • key in getItem builder block only accepts the class which generate the schemas, instead of the type of DynamoDbPartitionKey defined in the class.

Steps to Reproduce

Using Java 23 and Kotlin 2.1.10

Data class to generate Schema

@DynamoDbItem
data class Planet(
    @DynamoDbPartitionKey
    val name: String,
    val id: Long
)

Use getItem(), calling the getPlanet() with a Spring boot controller gives the error

    suspend fun getPlanet(): Planet? {
        val planetTable = mapper.getTable("planet-table", PlanetSchema)
        return planetTable.getItem("Jupiter")
    }

Use getItem { }

    suspend fun getPlanet(): Planet? {
        val planetTable = mapper.getTable("planet-table", PlanetSchema)
        return planetTable.getItem { key = "Jupiter" }.item
    }

Possible Solution

No response

Context

No response

AWS SDK for Kotlin version

1.4.58

Platform (JVM/JS/Native)

JVM

Operating system and version

macOS

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions