{"record":{"id":"872582934baddd40","repo":"instructure/canvas-lms","slug":"not-found-update-institutional-tag","errorCode":null,"errorMessage":"not found","messagePattern":"not found","errorType":"exception","errorClass":"GraphQL::ExecutionError","httpStatus":null,"severity":"error","filePath":"app/graphql/mutations/update_institutional_tag.rb","lineNumber":44,"sourceCode":"             ID,\n             required: false,\n             prepare: GraphQLHelpers.relay_or_legacy_id_prepare_func(\"InstitutionalTagCategory\")\n    argument :description, String, required: false\n    argument :id,\n             ID,\n             required: true,\n             prepare: GraphQLHelpers.relay_or_legacy_id_prepare_func(\"InstitutionalTag\")\n    argument :name, String, required: false\n\n    field :institutional_tag, Types::InstitutionalTagType, null: true\n\n    def resolve(input:)\n      root_account = context[:domain_root_account]\n      raise GraphQL::ExecutionError, \"feature flag is disabled\" unless root_account.feature_enabled?(:institutional_tags)\n      raise GraphQL::ExecutionError, \"not authorized\" unless root_account.grants_right?(current_user, session, :manage_institutional_tags_edit)\n\n      tag = InstitutionalTag.where(root_account_id: root_account.id, workflow_state: \"active\").find_by(id: input[:id])\n      raise GraphQL::ExecutionError, \"not found\" unless tag\n\n      attrs = {}\n      attrs[:name] = input[:name] if input.key?(:name)\n      attrs[:description] = input[:description] if input.key?(:description)\n\n      if input.key?(:category_id)\n        category = root_account.institutional_tag_categories.where(workflow_state: \"active\").find_by(id: input[:category_id])\n        raise GraphQL::ExecutionError, \"not found\" unless category\n\n        attrs[:category_id] = category.id\n      end\n\n      if tag.update(attrs)\n        { institutional_tag: tag }\n      else\n        errors_for(tag)\n      end\n    rescue ActiveRecord::RecordInvalid","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/app/graphql/mutations/update_institutional_tag.rb#L26-L62","documentation":"After flag and permission checks pass, updateInstitutionalTag looks up the tag scoped to root_account_id and workflow_state 'active' with find_by(id:). If no matching active tag exists, it raises GraphQL::ExecutionError \"not found\". Note this is a find_by nil check, not a rescued RecordNotFound.","triggerScenarios":"Calling updateInstitutionalTag with an id that doesn't exist; the tag exists but is soft-deleted/archived (workflow_state != 'active'); the tag belongs to a different root account.","commonSituations":"Archiving a tag via updateInstitutionalTagArchivedState then trying to edit it with the plain update mutation; cross-tenant id reuse in multi-tenant setups; stale UI listing a deleted tag.","solutions":["Confirm the tag is active: InstitutionalTag.where(root_account_id:, workflow_state: 'active').find_by(id:) in console.","If the tag is archived, use the archive-state mutation to undestroy it before editing.","Verify the id belongs to the same root account the request resolves to.","Refresh the tag list in the client to drop stale ids."],"exampleFix":"// before\nupdateInstitutionalTag(input: { id: archivedTagId, name: \"new\" })\n// after\nupdateInstitutionalTagArchivedState(input: { id: archivedTagId, archived: false })\nupdateInstitutionalTag(input: { id: archivedTagId, name: \"new\" })","handlingStrategy":"validation","validationCode":"// fetch only active tags and ensure the id is among them\nconst tags = await fetchActiveInstitutionalTags(rootAccountId)\nif (!tags.some(t => t.id === tagId)) throw new Error(`active tag ${tagId} not found`)","typeGuard":"const isActiveTag = (t) => !!t && t.workflowState === 'active'","tryCatchPattern":"try {\n  await updateInstitutionalTag(input)\n} catch (e) {\n  if (e.graphQLErrors?.some(g => g.message === 'not found')) {\n    await refreshTagList() // maybe archived or cross-account\n  } else { throw e }\n}","preventionTips":["Only allow editing tags loaded from an active-tags query.","Undestroy an archived tag first if it must be edited.","Never reuse tag ids across accounts/environments."],"tags":["graphql","ruby","activerecord","canvas-lms"],"backgroundTag":"record-not-found","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"}