{"record":{"id":"831915601b50a700","repo":"instructure/canvas-lms","slug":"sticker-is-required-provide-a-value-of-null-to-remove-a","errorCode":null,"errorMessage":"'sticker' is required. Provide a value of null to remove a sticker","messagePattern":"'sticker' is required\\. Provide a value of null to remove a sticker","errorType":"exception","errorClass":"GraphQL::ExecutionError","httpStatus":null,"severity":"error","filePath":"app/graphql/mutations/update_submission_sticker.rb","lineNumber":29,"sourceCode":"#\n# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY\n# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR\n# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n# details.\n#\n# You should have received a copy of the GNU Affero General Public License along\n# with this program. If not, see <http://www.gnu.org/licenses/>.\n#\nclass Mutations::UpdateSubmissionSticker < Mutations::BaseMutation\n  argument :anonymous_id, ID, required: true\n  argument :assignment_id, ID, required: true\n  argument :sticker, Types::StickerType, required: false\n\n  field :submission, Types::SubmissionType, null: false\n\n  def resolve(input:)\n    # Ideally we would use required: :nullable above for sticker, but it doesn't seem to work...\n    raise GraphQL::ExecutionError, \"'sticker' is required. Provide a value of null to remove a sticker\" unless input.key?(:sticker)\n\n    submission = Submission.find_by(\n      root_account: context[:domain_root_account],\n      assignment_id: input.fetch(:assignment_id),\n      anonymous_id: input.fetch(:anonymous_id)\n    )\n\n    raise GraphQL::ExecutionError, \"not found\" if submission.nil? || !submission.grants_right?(current_user, :grade)\n    raise GraphQL::ExecutionError, \"Stickers feature flag must be enabled\" unless submission.course.feature_enabled?(:submission_stickers)\n\n    if submission.update(sticker: input.fetch(:sticker))\n      { submission: }\n    else\n      errors_for(submission)\n    end\n  end\nend\n","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/app/graphql/mutations/update_submission_sticker.rb#L11-L47","documentation":"UpdateSubmissionSticker mutation requires the sticker argument key to be present in the input, even when removing a sticker (value must be explicitly null). Because the argument is declared required: false, GraphQL omits absent keys, so the mutation checks input.key?(:sticker) and raises when the key is missing entirely.","triggerScenarios":"Calling updateSubmissionSticker without passing sticker at all, intending to remove a sticker but sending no field, or a client that strips null values from the variables payload.","commonSituations":"Client serialization (e.g. omitting undefined/null in JSON bodies); developer assumes absence equals removal; older client versions predating the sticker field.","solutions":["Always pass sticker explicitly, sending null to remove it","Ensure your HTTP client does not drop null-valued variables","Add sticker: null in the mutation variables object","Default the UI to send the current sticker value when unchanged"],"exampleFix":"// before\nupdateSubmissionSticker(input: {assignmentId, anonymousId}) // key omitted\n// after\nupdateSubmissionSticker(input: {assignmentId, anonymousId, sticker: null}) // removes sticker","handlingStrategy":"validation","validationCode":"const vars = {assignmentId, anonymousId}; if (!('sticker' in vars)) vars.sticker = currentSticker ?? null;","typeGuard":null,"tryCatchPattern":"try { await gql(updateSubmissionStickerMutation, vars) } catch (e) { if (/sticker' is required/.test(e.message)) vars.sticker = null; else throw e } // then retry","preventionTips":["Always include the sticker key explicitly, null to remove","Configure your fetch layer to serialize null variables","Add a client-side required-key check before sending"],"tags":["graphql","validation","missing-argument"],"backgroundTag":"missing-required-argument","analyzedSha":"1c9f0bb8013ed69c4f2efe11fd483025469b7e6c","analyzedAt":"2026-09-15T20:33:18.891Z","contentChangedAt":"2026-09-15T20:33:18.891Z","schemaVersion":2},"datasetVersion":"2026-09-23T02:17:17.105Z"}