Quest scroll not given to quest leader when questline quest finished
#10,421 opened on Jun 3, 2018
Description
Didymus (85f434a9-9315-4826-b634-2b5582d1a321) reports:
"i was the owner of a Golden Knight quest [goldenknight2] that my Party completed, but I did not get the Iron Knight [goldenknight3]. Cam you please make sure I get it? Thank you."
I've confirmed they were the quest leader, and the quest did run and complete, and they don't currently have the goldenknight3 quest scroll, and there was no indication in Amplitude of the scroll having been used. Below is data from Amplitude and the party's system messages showing the quest ownership, start event, and completion event.
I can't tell if they received the goldenknight2 achievement and other rewards because they already have several achievements for that quest and the rewards are just XP and GP (too hard to work out whether they were given).
I expect this was not from a code bug but instead from their account not being updated when the quest ended, e.g., due to a timeout or version error or something. There's nothing in Loggly for their User ID or the party's group ID at the time the quest ended.
This could be fixed by having try/catch/repeat code or similar in the quest completion code so that all required actions would be completed successfully, or by implementing transactions in the database (with code to retry a failed set of actions), which I believe we do want but it's not an easy thing to add. I'm marking this issue as suggestion-discussion - it's mostly just to record that this problem happened.
[From Amplitude](https://analytics.amplitude.com/org/3642/project/132025/search/85f434a9-9315-4826-b634-2b5582d1a321?eventFilter=quest):
User ID 85f434a9-9315-4826-b634-2b5582d1a321
Event Properties:
category behavior
owner true
questName goldenknight2
response accept
{
"_id" : "039bd88d-6ddb-41f3-8d2a-741391d0e543",
"id" : "039bd88d-6ddb-41f3-8d2a-741391d0e543",
"text" : "`Your quest, The Golden Knight, Part 2: Gold Knight, has started.`",
"timestamp" : ISODate("2018-05-31T16:38:20.291Z"),
"uuid" : "system",
"groupId" : "8a0bf2e6-ddce-4281-ab48-9b125d320658",
"_meta" : {
"participatingMembers" : "85f434a9-9315-4826-b634-2b5582d1a321, 667a73b4-0cb1-406d-a478-f225bd04a571, 73c80291-5d5f-4a2e-99f8-6ab3465d287b, 8b138e46-9047-40e3-93d2-8bfc41507899, d99d4ef7-bfa4-416c-a5fd-9d04882568ed"
},
"__v" : 0
}
{
"_id" : "ea3a2d18-574d-48c1-800d-c3d743b2f65e",
"id" : "ea3a2d18-574d-48c1-800d-c3d743b2f65e",
"text" : "`You defeated Gold Knight! Questing party members receive the rewards of victory.`",
"timestamp" : ISODate("2018-06-01T08:51:37.323Z"),
"uuid" : "system",
"groupId" : "8a0bf2e6-ddce-4281-ab48-9b125d320658",
"__v" : 0
}
I've given them the missing quest scroll and also increased the achievement for goldenknight2 since it's most likely they didn't get that either.
With PR #12335 the Habitica codebase has been updated to support MongoDB 4.2 and transactions making it possible to fix this issue.
Transactions allow operations on multiple documents to be executed ensuring that either all of them are executed correctly or none, making it possible to fix this issue.
An example on using transactions can be found at https://mongoosejs.com/docs/transactions.html while more info at https://docs.mongodb.com/manual/core/transactions/. If you want to work on this issue and have any question please leave a comment!