GraphQL 500 Internal Server Error : awardEmojiAdd mutation
Summary
The awardEmojiAdd GraphQL mutation resulted in a 500 Internal Server Error due to an undefined method 'find' for Awardable:Module error. The exception occurred during the process of locating a resource by Global ID (GID), where the expected method find was not available for the Awardable module.
Steps to Reproduce
Execute the following GraphQL mutation as a string: "mutation awardEmojiAdd($input: AwardEmojiAddInput!) { awardEmojiAdd(input: $input) { awardEmoji { description } clientMutationId errors } }"
Provide the input as a string: {"input": {"awardableId": "gid://gitlab/Awardable/1", "name": "random_string_49"}}
Example Project
GitLab instance running version 17.4.1-ce.
What is the current bug behavior?
The GraphQL mutation results in a 500 status code due to the following exception:
undefined method 'find' for Awardable:Module
The issue occurs in the mutation resolution process when attempting to find the Awardable resource using its Global ID (gid.model_class.find gid.model_id).
What is the expected correct behavior?
The expected behavior is for the mutation to correctly resolve the resource. If the resource does not exist, it should return a proper error message without causing a server crash or 500 Internal Server Error.
Relevant logs and/or screenshots
GraphQL Query: mutation awardEmojiAdd($input: AwardEmojiAddInput!) { awardEmojiAdd(input: $input) { awardEmoji { description } clientMutationId errors } }
Variables: {"input": {"awardableId": "gid://gitlab/Awardable/1", "name": "random_string_49"}}
Error Log: exception.class: NoMethodError exception.message: undefined method 'find' for Awardable:Module exception.backtrace:
globalid (1.1.0) lib/global_id/locator.rb:129:in 'locate' globalid (1.1.0) lib/global_id/locator.rb:154:in 'block in locate' globalid (1.1.0) lib/global_id/locator.rb:166:in 'unscoped' globalid (1.1.0) lib/global_id/locator.rb:154:in 'locate' globalid (1.1.0) lib/global_id/global_id.rb:49:in 'find' app/graphql/gitlab_schema.rb:100:in 'find_by_gid' lib/gitlab/graphql/authorize/authorize_resource.rb:49:in 'find_object' lib/gitlab/graphql/authorize/authorize_resource.rb:53:in 'authorized_find!' app/graphql/mutations/award_emojis/add.rb:9:in 'resolve'