Habitica: new tasks cannot be added to an existing challenge

Created on 22 Aug 2016  路  12Comments  路  Source: HabitRPG/habitica

When a challenge has already been created and saved, it is not possible to add new tasks to it (it should be possible). When you try, you see "Challenge not found or you don't have access." and the console reports:
POST https://habitica.com/api/v3/tasks/challenge/0b63cb69-8942-4a17-a506-9c3e4855616e?userV=13904 404 (Not Found)
That ID is the ID of the challenge.

important section all section creating / editing status in progress

Most helpful comment

Yep should be pretty easy to do, I can work on it!

All 12 comments

Sorry, this is something I should have caught in the last one. I'll look into this and try to get it resolved.

@Hus274 Thank you very much! I think it wasn't listed in the old one, so no blame to you!

Ok, so I thought I had tested this, I'm actually not able to replicate this on my local system. I've added a new habit, new daily, new todo, and new reward all locally after completely setting up the challenge and refreshing. Can you provide any more information around this so I can better try to replicate the issue?

I tested earlier by choosing a challenge I'd created in the past, clicking its edit button, and then I tried to add new tasks to it.

I've just tested now by creating a new challenge, saving it, then editing it, and the bug doesn't occur with it.

Looks like we'll need to work out what conditions cause it.

Hmm that's strange, there wasn't any change to the actual challenge in the database so the code shouldn't be able to tell the difference between a new challenge and an old challenge. I'll try to think about this a bit more to see if I can come up with something

Would having a link to the challenge that is causing me problems help? I don't know when the new version of the code went live, but I only created this challenge at the weekend.

https://habitica.com/#/options/groups/challenges/663aae43-87c2-40bb-a25e-f2077f03b7b9

I set up the Habit and Dailies, but didn't have time to look up all the links I wanted to include in the To-Dos, so saved it to finish later. but when I tried to complete it yesterday, though I could edit the existing tasks and the changes saved, adding a new task appeared to work but once saved, the changes disappeared.

The only thing I could think of looking at that challenge that might be different from what I tested was that you're trying to add to an empty list, but I'm not sure why that would make a difference. Does it work if you try and add a new habit?

It has to be being thrown here: https://github.com/HabitRPG/habitrpg/blob/develop/website/server/controllers/api-v3/tasks.js#L123

so from this it looks like one of the following has to be true
!challenge || user.challenges.indexOf(challengeId) === -1

It seems unlikely to me that the challenge doesn't exist which makes me think that it's not in the user's challenges array. Would this be something that we could check in the database to see which is the case? They both seem like a problem with how the challenge was set up.

@Hus274 Ah, good catch! When I leave a challenge I own, I cannot edit it, when I rejoin, I can.

@Dewines as a workaround, you'll be able to edit your challenges if you become a participant temporarily. Sorry about the hassle!

@Hus274 If you'd like to fix that, you'd be welcome to! There should be no requirement for a challenge owner to be a participant in their own challenges. They should still have full control over them even when they aren't participating. If you'd rather someone else worked on it, let us know!

Yep should be pretty easy to do, I can work on it!

@Alys No problem. I've been out all day today, but I'll rejoin the challenge tomorrow to finish editing and then leave it again. Though as you say, it used to be possible to keep total control of a challenge, including editing, even while not a member. But it's fine as a workaround until the glitch is sorted.

The reason I left was because when I first created it, I'd added the habit and the dailies but didn't have time to look up all the links I wanted to include in the To-Dos, I just saved it at that point, switched off my computer and forgot all about it. The next morning I died! I'd forgotten that creating the challenge added the tasks to my list and I hadn't checked them off! Thank heaven for Fix Character Values. Anyway, that's why I promptly left the challenge before it happened again. :)

Pull Request has been posted.

Was this page helpful?
0 / 5 - 0 ratings