{"record":{"id":"bd42f5c1c9f0ca4f","repo":"instructure/canvas-lms","slug":"feature-flag-is-disabled","errorCode":null,"errorMessage":"feature flag is disabled","messagePattern":"feature flag is disabled","errorType":"exception","errorClass":"GraphQL::ExecutionError","httpStatus":null,"severity":"error","filePath":"app/graphql/mutations/apply_institutional_tag.rb","lineNumber":38,"sourceCode":"\n# NOTE: Depends on InstitutionalTag, InstitutionalTagAssociation models\n\nmodule Mutations\n  class ApplyInstitutionalTag < BaseMutation\n    argument :tag_id,\n             ID,\n             required: true,\n             prepare: GraphQLHelpers.relay_or_legacy_id_prepare_func(\"InstitutionalTag\")\n    argument :user_id,\n             ID,\n             required: true,\n             prepare: GraphQLHelpers.relay_or_legacy_id_prepare_func(\"User\")\n\n    field :institutional_tag_association, Types::InstitutionalTagAssociationType, null: true\n\n    def resolve(input:) # rubocop:disable GraphQL/UnusedArgument\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[:tag_id])\n      raise GraphQL::ExecutionError, \"not found\" unless tag\n\n      user = root_account.all_users.find_by(id: input[:user_id])\n      raise GraphQL::ExecutionError, \"not found\" unless user\n\n      assoc = InstitutionalTagAssociation.find_or_initialize_by(\n        institutional_tag: tag,\n        context: user,\n        root_account:\n      )\n      assoc.workflow_state = \"active\"\n\n      if assoc.save\n        { institutional_tag_association: assoc }\n      else","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/app/graphql/mutations/apply_institutional_tag.rb#L20-L56","documentation":"This GraphQL mutation error means the `institutional_tags` feature flag is not enabled on the domain root account, so ApplyInstitutionalTag.resolve refuses to run before checking anything else. Canvas gates institutional tag management behind an account-level feature flag; the mutation raises GraphQL::ExecutionError immediately when the flag is off.","triggerScenarios":"Calling the applyInstitutionalTag GraphQL mutation on an account where root_account.feature_enabled?(:institutional_tags) returns false (flag never enabled, enabled only at a sub-account, or enabled in a different environment).","commonSituations":"Dev/test environments where the flag was never turned on; calling against a shard/account different from the one where the flag was enabled; flag enabled only for a site admin account rather than the domain root account; forgetting `Account.site_admin.feature_owners` / enable_feature_flag setup in specs.","solutions":["Enable the feature flag on the domain root account: in Rails console run `root_account.set_feature_flag!` or via Account UI Settings > Feature Options > Institutional Tags.","If testing, wrap the spec/request in `Account.site_admin.enable_feature!(...)` or stub `feature_enabled?(:institutional_tags)` to return true.","Verify context[:domain_root_account] is the account you think it is (shard/sub-account mismatch).","Check that the mutation is being sent against the intended Canvas environment (prod vs test accounts have separate flag settings)."],"exampleFix":"// before (client): mutation fails with 'feature flag is disabled'\napplyInstitutionalTag(input: { tagId: 1, userId: 2 })\n\n// after (server setup): enable the flag first\nAccount.find(root_account_id).enable_feature!(:institutional_tags)","handlingStrategy":"validation","validationCode":"# before calling the mutation\nacct = context[:domain_root_account]\nraise 'flag off' unless acct.feature_enabled?(:institutional_tags)\n","typeGuard":"def flag_enabled?(account, flag)\n  account.respond_to?(:feature_enabled?) && account.feature_enabled?(flag)\nend","tryCatchPattern":"begin\n  result = canvas_graphql.mutation(APPLY_TAG, vars)\nrescue GraphQL::ExecutionError => e\n  retry_after_enabling_flag if e.message == 'feature flag is disabled'\nend","preventionTips":["Enable the flag in every environment where the feature is used","Add a smoke test asserting the flag is on","Check flag state in UI before exposing the mutation"],"tags":["graphql","feature-flag","canvas-lms","mutation"],"backgroundTag":"feature-not-enabled","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"}