{"record":{"id":"3d02bc46292090d4","repo":"instructure/canvas-lms","slug":"not-found-update-institutional-tag-archived-state","errorCode":null,"errorMessage":"not found","messagePattern":"not found","errorType":"exception","errorClass":"GraphQL::ExecutionError","httpStatus":null,"severity":"error","filePath":"app/graphql/mutations/update_institutional_tag_archived_state.rb","lineNumber":39,"sourceCode":"# NOTE: Depends on InstitutionalTag and InstitutionalTagAssociation models\n\nmodule Mutations\n  class UpdateInstitutionalTagArchivedState < BaseMutation\n    argument :archived, Boolean, required: true\n    argument :id,\n             ID,\n             required: true,\n             prepare: GraphQLHelpers.relay_or_legacy_id_prepare_func(\"InstitutionalTag\")\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).find_by(id: input[:id])\n      raise GraphQL::ExecutionError, \"not found\" unless tag\n\n      input[:archived] ? tag.destroy : tag.undestroy\n\n      { institutional_tag: tag }\n    rescue ActiveRecord::RecordInvalid\n      errors_for(tag)\n    rescue ActiveRecord::RecordNotFound\n      raise GraphQL::ExecutionError, \"not found\"\n    end\n  end\nend\n","sourceCodeStart":21,"sourceCodeEnd":51,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/app/graphql/mutations/update_institutional_tag_archived_state.rb#L21-L51","documentation":"updateInstitutionalTagArchivedState loads the tag with InstitutionalTag.where(root_account_id: root_account.id).find_by(id:) — this variant does not filter on workflow_state, but still requires the record to exist under the current root account. If find_by returns nil it raises \"not found\". The resolver's trailing rescue of ActiveRecord::RecordNotFound provides the same message for any RecordNotFound raised later (e.g. during undestroy).","triggerScenarios":"Passing an id that doesn't exist at all, belongs to a different root account, or is not decodable as an InstitutionalTag Relay id; a RecordNotFound raised from tag.undestroy when an unarchived state conflicts.","commonSituations":"Archiving an already-archived tag with a stale id; cross-account ids copied between environments; Relay id prepared for a different object type so the resolved raw id does not match any InstitutionalTag row.","solutions":["Confirm the tag exists under this root account: InstitutionalTag.where(root_account_id: root_account.id).find_by(id:) in console.","Verify the Relay id is encoded for the InstitutionalTag type, not another type.","Check the request resolves to the same root account that owns the tag.","Handle the GraphQL errors entry and refresh the tag list before retrying."],"exampleFix":"// before\nupdateInstitutionalTagArchivedState(input: { id: otherAccountTagId, archived: true })\n// after\nconst tag = tagsByAccount[rootAccountId]?.find(t => t.id === tagId)\nif (!tag) throw new Error('tag not found for this account')\nupdateInstitutionalTagArchivedState(input: { id: tagRelayId, archived: true })","handlingStrategy":"validation","validationCode":"// confirm the tag exists under this account before archiving\nconst tags = await fetchAllInstitutionalTags(rootAccountId) // includes archived\nif (!tags.some(t => t.id === tagId)) throw new Error(`tag ${tagId} not found for this account`)","typeGuard":"const isInstitutionalTag = (t) => !!t && t.__typename === 'InstitutionalTag'","tryCatchPattern":"try {\n  await updateInstitutionalTagArchivedState(input)\n} catch (e) {\n  if (e.graphQLErrors?.some(g => g.message === 'not found')) {\n    await refreshTagList() // wrong account or bad relay id\n  } else { throw e }\n}","preventionTips":["Encode ids with the InstitutionalTag relay type, never reuse other types' ids.","Verify the tag belongs to the resolving root account before mutating.","Refresh the tag list (including archived) before retrying archive state changes."],"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"}