{"record":{"id":"3a20c5bcfa8c0746","repo":"instructure/canvas-lms","slug":"must-specify-exactly-one-of-id-or-name","errorCode":null,"errorMessage":"Must specify exactly one of id or name","messagePattern":"Must specify exactly one of id or name","errorType":"exception","errorClass":"GraphQL::ExecutionError","httpStatus":null,"severity":"error","filePath":"app/graphql/types/query_type.rb","lineNumber":350,"sourceCode":"               \"a graphql or legacy id\",\n               required: true,\n               prepare: GraphQLHelpers.relay_or_legacy_id_prepare_func(\"LearningOutcome\")\n    end\n    def learning_outcome(id:)\n      GraphQLNodeLoader.load(\"LearningOutcome\", id, context)\n    end\n\n    field :internal_setting, Types::InternalSettingType, null: true do\n      description \"Retrieves a single internal setting by its ID or name\"\n      argument :id,\n               ID,\n               \"a graphql or legacy id\",\n               required: false,\n               prepare: GraphQLHelpers.relay_or_legacy_id_prepare_func(\"InternalSetting\")\n      argument :name, String, \"the name of the Setting\", required: false\n    end\n    def internal_setting(id: nil, name: nil)\n      raise GraphQL::ExecutionError, \"Must specify exactly one of id or name\" if (id && name) || !(id || name)\n\n      return GraphQLNodeLoader.load(\"InternalSetting\", id, context) if id\n\n      GraphQLNodeLoader.load(\"InternalSettingByName\", name, context) if name\n    end\n\n    field :internal_settings, [Types::InternalSettingType], null: true do\n      description \"All internal settings\"\n    end\n    def internal_settings\n      return [] unless Account.site_admin.grants_right?(context[:current_user], context[:session], :manage_internal_settings)\n\n      Setting.all\n    end\n\n    field :account_notifications, [Types::AccountNotificationType], null: false do\n      description \"Account notifications for the current user\"\n      argument :account_id, ID, \"Account ID to fetch notifications for\", required: false","sourceCodeStart":332,"sourceCodeEnd":368,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/app/graphql/types/query_type.rb#L332-L368","documentation":"The `internal_setting` resolver requires exactly one of an `id` (graphql/legacy ID) or a `name` (the Setting's string name). Both or neither is ambiguous and raises this GraphQL::ExecutionError before loading the node.","triggerScenarios":"query { internalSetting(id: \"...\", name: \"...\") } (both) or query { internalSetting } with neither argument.","commonSituations":"Ops tooling that normally looks settings up by name keeps a stale id variable after a refactor; scripts that template all optional arguments into the query; empty-string name serializing alongside an id.","solutions":["Pass exactly one of id or name; drop the other.","If you only know the setting name, use the name path and omit id entirely.","Omit unset variables so empty strings are not serialized as present arguments."],"exampleFix":"// before\nquery { internalSetting(id: \"12\", name: \"DefaultMigrationDelay\") { value } }\n// after\nquery { internalSetting(name: \"DefaultMigrationDelay\") { value } }","handlingStrategy":"validation","validationCode":"const n = [vars.id, vars.name].filter(v => v != null && v !== '').length;\nif (n !== 1) throw new Error('internalSetting requires exactly one of id or name');","typeGuard":"const settingArgsValid = (vars) => Boolean(vars.id) !== Boolean(vars.name);","tryCatchPattern":"try { return await gql(SETTING_QUERY, vars); } catch (e) { if (e.message.includes('exactly one of id or name')) { vars = vars.id ? { id: vars.id } : { name: vars.name }; return retry(vars); } throw e; }","preventionTips":["For name lookups, never carry a leftover id variable from prior calls.","Validate variables in one shared helper used by all settings tooling.","Avoid empty-string names; treat them as absent and strip them."],"tags":["graphql","validation","arguments"],"backgroundTag":"mutually-exclusive-options","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"}