{"record":{"id":"6fb6124036d19825","repo":"instructure/canvas-lms","slug":"feature-flag-is-disabled-create-institutional-tag","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/create_institutional_tag.rb","lineNumber":36,"sourceCode":"# with this program. If not, see <http://www.gnu.org/licenses/>.\n#\n\n# NOTE: Depends on InstitutionalTag and InstitutionalTagCategory models\n\nmodule Mutations\n  class CreateInstitutionalTag < BaseMutation\n    argument :category_id,\n             ID,\n             required: true,\n             prepare: GraphQLHelpers.relay_or_legacy_id_prepare_func(\"InstitutionalTagCategory\")\n    argument :description, String, required: true\n    argument :name,        String, required: true\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_create)\n\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      max_tags = DynamicSettings.find(\"institutional_tags\")[\"max_tags_per_category\", failsafe: nil]&.to_i || 50\n      if category.institutional_tags.where(workflow_state: \"active\").count >= max_tags\n        raise GraphQL::ExecutionError, \"category has reached the maximum number of tags\"\n      end\n\n      tag = category.institutional_tags.new(\n        name: input[:name],\n        description: input[:description],\n        root_account:\n      )\n\n      if tag.save\n        { institutional_tag: tag }","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/app/graphql/mutations/create_institutional_tag.rb#L18-L54","documentation":"CreateInstitutionalTag checks the institutional_tags feature flag on the domain root account before doing anything. If the flag is off, it raises this GraphQL::ExecutionError. This is a deliberate gate: the institutional tagging feature is not enabled for the account, so the mutation must not run.","triggerScenarios":"Calling createInstitutionalTag on any account where root_account.feature_enabled?(:institutional_tags) is false — typically staging/production accounts without the flag, or environments where the FF was never applied.","commonSituations":"Testing the new institutional-tags feature locally without enabling the flag; an environment (beta/prod) where the rollout has not happened; calling the mutation on a root account different from the one the flag was set on; feature flag later rolled back.","solutions":["Enable the feature flag: rails console -> root_account.enable_feature!(:institutional_tags) or Account > Settings > Feature Options.","Confirm context[:domain_root_account] is the account you enabled the flag on.","Check flag definition (allowed/hidden, environment overrides in feature flags yml).","If flag should already be on, verify no caching issue — restart or clear feature-flag caches."],"exampleFix":"// before\nroot_account.feature_enabled?(:institutional_tags) # => false\n// after (console)\nAccount.default.set_feature_flag!('institutional_tags', 'on') # then retry mutation","handlingStrategy":"validation","validationCode":"// client-side gate before the mutation call\nif (!account.featureFlags.includes('institutional_tags')) {\n  throw new Error('institutional_tags feature flag is not enabled for this account');\n}","typeGuard":"function institutionalTagsEnabled(account) {\n  return Boolean(account && account.featureFlags && account.featureFlags.includes('institutional_tags'));\n}","tryCatchPattern":"try {\n  await createInstitutionalTag({ variables })\n} catch (e) {\n  if (e.message === 'feature flag is disabled') {\n    // surface an admin-facing 'enable institutional tags' hint instead of retrying\n  }\n}","preventionTips":["Enable the flag in every environment you test against","Query an account featureFlags field before invoking gated mutations","Keep flag rollout docs in sync between local, beta, and prod","Remember the gate is on the domain root account, not sub-accounts"],"tags":["graphql","feature-flag","permissions","canvas"],"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"}