{"record":{"id":"b9d4d63903019d5c","repo":"instructure/canvas-lms","slug":"not-found-create-institutional-tag-category","errorCode":null,"errorMessage":"not found","messagePattern":"not found","errorType":"exception","errorClass":"GraphQL::ExecutionError","httpStatus":null,"severity":"error","filePath":"app/graphql/mutations/create_institutional_tag_category.rb","lineNumber":48,"sourceCode":"    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.new(\n        name: input[:name],\n        description: input[:description]\n      )\n\n      if category.save\n        { institutional_tag_category: category }\n      else\n        errors_for(category)\n      end\n    rescue ActiveRecord::RecordInvalid\n      errors_for(category)\n    rescue ActiveRecord::RecordNotFound\n      raise GraphQL::ExecutionError, \"not found\"\n    end\n  end\nend\n","sourceCodeStart":30,"sourceCodeEnd":52,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/app/graphql/mutations/create_institutional_tag_category.rb#L30-L52","documentation":"CreateInstitutionalTagCategory rescues ActiveRecord::RecordNotFound and re-raises it as this 'not found' GraphQL::ExecutionError. Nothing in the happy path calls find; this is almost always the argument ID preparation (relay/legacy id helper) or a nested lookup raising RecordNotFound, converted into a GraphQL error.","triggerScenarios":"An invalid or foreign global ID supplied in a related argument processed by ID preparation helpers, or any find!-style lookup inside resolve failing — though for this mutation, creation-only, the ID preparer is the usual source.","commonSituations":"Malformed relay ID strings; IDs from the wrong shard; a client sending legacy numeric IDs where global IDs are expected (or vice versa) with a mismatched prepare function.","solutions":["Verify all ID arguments are well-formed InstitutionalTagCategory global IDs.","Check shard/scope: the ID must resolve in the current account's shard.","Fetch a fresh category via the institutionalTagCategories query and reuse its ID.","If it persists, log the raised ActiveRecord::RecordNotFound message (GraphQL error extensions/traces) to identify the exact lookup that failed."],"exampleFix":"// before\ncreateInstitutionalTagCategory(input: { name: \"Difficulty\" }) // with a corrupt custom context id raising RecordNotFound\n// after\nconst ctx = { domainRootAccount: account }; // ensure valid GraphQL context\ncreateInstitutionalTagCategory({ variables: { name: 'Difficulty', description: 'Levels' } })","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isWellFormedId(id) {\n  return typeof id === 'string' && /^[A-Za-z]+-\\d+$/.test(id); // basic global-id shape check\n}","tryCatchPattern":"try {\n  await createInstitutionalTagCategory({ variables })\n} catch (e) {\n  if (e.message === 'not found') {\n    // inspect request variables; a RecordNotFound was converted — validate every ID argument\n  }\n}","preventionTips":["Pass only server-issued IDs for typed fields","Avoid hand-constructing global IDs; use fromGlobalId/toGlobalId helpers","Run mutations on the correct shard","If a 'not found' appears without an ID argument, inspect server traces for the raising lookup"],"tags":["graphql","not-found","ruby","activerecord"],"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"}