maproulette3 icon indicating copy to clipboard operation
maproulette3 copied to clipboard

Users with null `users.avatar_url` Causes Error in `GET /api/v2/challenge/1/comments` Endpoint

Open ljdelight opened this issue 2 years ago • 1 comments

Describe the bug

I found that when a user with users.avatar_url=null, such as the system superuser (id=-999), submits a comment on a challenge/task the MapRoulette UI subsequently blows up for all users when attempting to load the challenge/task.

The comments parser doesn't appreciate a null entry for users.avatar_url. I'm using the system superuser (in a local dev environment) and it does default the avatar_url to null, but this could apply to other users.

Optimal fix: The users.avatar_url should not allow null and instead should use a safe default of /assets/images/user_no_image.png. Or I suppose the parser could be fixed.

Expected behavior The request GET /api/v2/challenge/1/comments should not fail due to a possible null-value of users.avatar_url.

To Reproduce

Within your local dev environment, use the system superuser to add a comment to a task. Then load that within the UI.

Screenshots The screenshot shows the issue within the browser image

Intellij log:

21:20:26.737 [info][81cca537-a9bf-4347-a615-2e7692d0803b][application-akka.actor.default-dispatcher-24] AccessLogger.$anonfun$apply$1(HttpLoggingFilter.scala:47) - Request 'GET /api/v2/challenge/1/comments' [org.maproulette.controllers.api.ChallengeController.retrieveComments] 5ms - Response 500

21:20:26.737 [error][][scala-execution-context-global-144739] o.m.e.MPExceptionUtil$.manageException(MPExceptionUtil.scala:91) - 'users.avatar_url' not found, available columns: task_comments.id, id, task_comments.osm_id, osm_id, task_comments.task_id, task_id, task_comments.created, created, task_comments.comment, comment, task_comments.action_id, action_id, task_comments.challenge_id, challenge_id, task_comments.project_id, project_id, users.id, id, users.osm_id, osm_id, users.created, created, users.modified, modified, users.osm_created, osm_created, users.name, name, users.description, description, users.avatar_url, avatar_url, users.api_key, api_key, users.oauth_token, oauth_token, users.oauth_secret, oauth_secret, users.home_location, home_location, users.default_editor, default_editor, users.default_basemap, default_basemap, users.email_opt_in, email_opt_in, users.locale, locale, users.theme, theme, users.properties, properties, users.leaderboard_opt_out, leaderboard_opt_out, users.default_basemap_id, default_basemap_id, users.needs_review, needs_review, users.is_reviewer, is_reviewer, users.email, email, users.following_group, following_group, users.followers_group, followers_group, users.allow_following, allow_following, users.see_tag_fix_suggestions, see_tag_fix_suggestions
anorm.AnormException: 'users.avatar_url' not found, available columns: task_comments.id, id, task_comments.osm_id, osm_id, task_comments.task_id, task_id, task_comments.created, created, task_comments.comment, comment, task_comments.action_id, action_id, task_comments.challenge_id, challenge_id, task_comments.project_id, project_id, users.id, id, users.osm_id, osm_id, users.created, created, users.modified, modified, users.osm_created, osm_created, users.name, name, users.description, description, users.avatar_url, avatar_url, users.api_key, api_key, users.oauth_token, oauth_token, users.oauth_secret, oauth_secret, users.home_location, home_location, users.default_editor, default_editor, users.default_basemap, default_basemap, users.email_opt_in, email_opt_in, users.locale, locale, users.theme, theme, users.properties, properties, users.leaderboard_opt_out, leaderboard_opt_out, users.default_basemap_id, default_basemap_id, users.needs_review, needs_review, users.is_reviewer, is_reviewer, users.email, email, users.following_group, following_group, users.followers_group, followers_group, users.allow_following, allow_following, users.see_tag_fix_suggestions, see_tag_fix_suggestions

ljdelight avatar Dec 12 '23 03:12 ljdelight

I checked and only the system superuser has a null entry for avatar_url. Code paths need verified so that this null cannot creep to users. edit: a pg constraint would be a good idea since the code doesn't expect null

ljdelight avatar Dec 12 '23 04:12 ljdelight