Reputation: 356
In what has been the least helpful error message of 2021, my createUser
mutation, despite being passed inputs satisfying all requirements, throws this bummer of a message:
data: {createUser: null}
errors: [{path: ["createUser"], data: null, errorType: "ConditionalCheckFailedException", errorInfo: null,…}]
0: {path: ["createUser"], data: null, errorType: "ConditionalCheckFailedException", errorInfo: null,…}
data: null
errorInfo: null
errorType: "ConditionalCheckFailedException"
locations: [{line: 2, column: 3, sourceName: null}]
0: {line: 2, column: 3, sourceName: null}
column: 3
line: 2
sourceName: null
message: "The conditional request failed (Service: DynamoDb, Status Code: 400, Request ID: 70BUB7TAU32M7JGGO6324LGR53VV4KQNSO5AEMVJF6ZZ6ZQ9ASUAAJG, Extended Request ID: null)"
path: ["createUser"]
My schema:
type ScheduledEmail @model @auth(rules: [{allow: public}]) {
id: ID!
frequency: Frequency!
scheduleHour: ScheduleHour!
scheduleStart: ScheduleStart!
user: [User] @connection(keyName: "byScheduledEmail", fields: ["id"])
}
type User @model @auth(rules: [{allow: public}]) @key(name: "byScheduledEmail", fields: ["scheduledEmailId"]) {
id: ID!
email: String!
subscriptions: [ID]!
name: String
scheduledEmailId: ID
scheduledEmail: ScheduledEmail @connection
}
When keys and values have been mismatched, dynamodb has been kind of enough to be specific about it. I haven't provided it a condition so I'm not sure how it can be failing.
Thanks in advance.
Upvotes: 2
Views: 622
Reputation: 93
This is the result I get when a value with the same ID already exists. It doesn't seem very descriptive but I bet in this example previous unit tests had already created records with those IDs. Thus removing the ID forced the generation of a new one, thus satisfying the condition that the ID not already exist.
Upvotes: 0
Reputation: 356
I was passing to the mutation a unique ID that I needed to generate myself which it apparently doesn't like. Arg.
Upvotes: 1