I have a model that looks like this:
class Task(BaseModel):
Meta = pynamodb_table_meta("my-task")
creator_id = UnicodeAttribute(null=False)
metadata = JSONAttribute(default={}, null=False)
status = UnicodeAttribute(default="new", null=False)
task_id = UnicodeAttribute(hash_key=True)
class BaseModel(Model):
created_at = UTCDateTimeAttribute()
updated_at = UTCDateTimeAttribute()
Controller code:
try:
task_to_be_updated = Task(task_id='valid uuid of existing task')
with TransactWrite(connection=connection) as transaction:
now = datetime.utcnow()
transaction.update(
task_to_be_updated,
actions=[
Task.creator_id.set("new uuid")
Task.status.set("in_progress"),
Task.updated_at.set(now)
],
condition=(Task.status == "new")
)
except TransactWriteError as e:
raise Exception(f"Task error {e.cause_response_code}")
The transaction.update always fails with a ValidationException. Not sure what the issue is. If there is a way to understand where the ValidationException happened, that would be great since all I see is "Task error ValidationException" hence no idea which field is causing problems.