HabitRPG / habitica

A habit tracker app which treats your goals like a Role Playing Game.
https://habitica.com
Other
12k stars 4.1k forks source link

guild creation failing, gems being taken #12124

Closed Alys closed 2 years ago

Alys commented 4 years ago

Recently we've seen two reports of people trying to make a guild, having their Gems removed, but the guild not existing.

This one from @Muamua (1039bae3-1101-4c9f-8ad1-416b04ecd93d) was 15 hours before now: "Then I logged in on website version and create guild but it occur error. After that, my gems disappeared but my guild didn't created.."_

This one from @tymeczekxpompa (1e3a7b23-5fde-44d5-b742-12e848f93f4d) was from 10 days ago: "When I was creating the private guild and clicked "create a guild" button an error happened which took my 4 gems but hasn't created any guild."

In both cases I found a group ID in their guilds array that did not correspond to a guild that currently exists (ca200a70-1f0f-48f3-8423-4ed02c8b05bb and 2d69ff05-e763-488a-9706-b3a0f9bed748 respectively). Those IDs are still there but we should remove them eventually.

The Amplitude/Loggly event type for creating a guild is json.event_type:"join group" (code ref.), i.e., the same as for joining a guild, however it would have json.event_properties.owner:"true" (true rather than false). I haven't found such a record in Loggly for @Muamua_, except for one from a few minutes ago (2020-04-26 04:00:12.240) which was after I gave them Gems and told them to true again. Either their failed attempt happened before that data started to go into Loggly, or (more likely) the guild creation failed before it got to the point where analytics were recorded.

I haven't found Loggly errors associated with this but I have not searched thoroughly. We probably should, I'm just a bit short of time today.

I've given 4 Gems to both of those people.


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!

Alys commented 4 years ago

I've labelled this as needs investigation and important priority since it's taking Gems and not all players would notice that.

Alys commented 4 years ago

More details from @Muamua_:

"I remember that the category which I select all replaced into other category that isn't exist when I clicked the create button. Then my gems gone and My guild didn't created because the category wasn't exist... I can't remember the error category's name, but it was obviously look like error like ----:------.:

"I select Academic, entertainment, and Hobbies and Occupation. Also I never checked privacy box. Now I create guild by your gems with checking privacy, then it worked."

I suspect the public/private setting wouldn't have been related to this bug. The category error is probably relevant and we at least should investigate it for its own sake.

paglias commented 4 years ago

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!

samamill commented 3 years ago

Can I work on this one?

paglias commented 3 years ago

sure @samamill ! I'm marking it as in progress for you

samamill commented 3 years ago

@paglias can you or another admin take a look? Another contributor signed off, but I think I need an admin to update the tags.

paglias commented 3 years ago

Sorry Sam but for the time being I won't be able to review PRs, @Sabrecat should be able to help you though

Il lun 25 gen 2021, 01:41 Sam notifications@github.com ha scritto:

@paglias https://github.com/paglias can you or another admin take a look? Another contributor signed off, but I think I need an admin to update the tags.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/HabitRPG/habitica/issues/12124#issuecomment-766472098, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEQAV6OGKJVO3SOIGVY2QTS3S44TANCNFSM4MRBREGA .

shanaqui commented 3 years ago

@samamill Hi! Are you still working on this one? Looks like it's been marked as back with you for tests to be added; will you be able to do that, or shall I set this back to help wanted? If we don't hear back, I'll do that in about a week. Thanks!

Cred1Tor commented 2 years ago

i can fix it, but i don't know how can you write a unit test for failing transaction i tested it manually by throwing an error before commiting transaction and the changes were reverted as expected

CuriousMagpie commented 2 years ago

Hey @Cred1Tor, can you put together a PR for this? Thanks!