GMBuddy / gmbuddy-backend

0 stars 0 forks source link

Cannot provide empty campaign value when modifying character. #24

Open garrickb opened 7 years ago

garrickb commented 7 years ago

You can recreate this buy creating a character, and then attempting to modify the character passing a "null" value for the campaign.

Response from server: {"Campaign":["The value 'null' is not valid for Campaign."]}

garrickb commented 7 years ago

I think that this may fix my other issue of not being able to remove the campaign from a user by sending "null" to the modify command. I'm just gonna go ahead and lump that in with this, but make sure that you test that.

jackhorton commented 7 years ago

There are two issues going on here. 1, the error itself likely comes from you using x-www-form-urlencoded - since there is no "null" value in that encoding, youre sending the string "null." I encountered this in Postman, and changing it to json with an actual null value does not throw the error.

However, it still is a problem, because I have no way to distinguish when you specifically send a null value (when you want to remove a character from a campaign) versus when you omit the value (when you are making a modification to something other than the campaign). We can either leave this as-is (once a character is in a campaign, it must always be in one, somewhere) or I can add a boolean field like "forceUpdateCampaignId" to know what "null" means.

garrickb commented 7 years ago

If it will be easy for it to know what "null" is, I think that would be a better solution, even though it seems a little haphazard.

jackhorton commented 7 years ago

so, boolean field specifically to mark whether or not you are intentionally setting campaignId to null? I suppose i could also fix this by just having another route to handle this specific case, rather than lumping it in with the rest of the character modifications.

jackhorton commented 7 years ago

Update -- changing to JSON actually makes the process silently fail. Please hold for new solution.