{"record":{"id":"833b573284dc6e21","repo":"instructure/canvas-lms","slug":"must-specify-an-id-or-an-assignment-id-and-user-id-or-an","errorCode":null,"errorMessage":"Must specify an id or an assignment_id and user_id or an assignment_id and an anonymous_id","messagePattern":"Must specify an id or an assignment_id and user_id or an assignment_id and an anonymous_id","errorType":"exception","errorClass":"GraphQL::ExecutionError","httpStatus":null,"severity":"error","filePath":"app/graphql/types/query_type.rb","lineNumber":160,"sourceCode":"               \"a graphql or legacy user id\",\n               required: false,\n               prepare: GraphQLHelpers.relay_or_legacy_id_prepare_func(\"User\")\n\n      argument :anonymous_id,\n               ID,\n               \"an anonymous id in use when grading anonymously\",\n               required: false\n    end\n\n    def submission(id: nil, assignment_id: nil, user_id: nil, anonymous_id: nil)\n      if id && !assignment_id && !user_id && !anonymous_id\n        GraphQLNodeLoader.load(\"Submission\", id, context)\n      elsif !id && assignment_id && user_id\n        GraphQLNodeLoader.load(\"SubmissionByAssignmentAndUser\", { assignment_id:, user_id: }, context)\n      elsif !id && assignment_id && anonymous_id\n        GraphQLNodeLoader.load(\"SubmissionByAssignmentAndAnonymousId\", { assignment_id:, anonymous_id: }, context)\n      else\n        raise GraphQL::ExecutionError, \"Must specify an id or an assignment_id and user_id or an assignment_id and an anonymous_id\"\n      end\n    end\n\n    field :term, Types::TermType, null: true do\n      argument :id,\n               ID,\n               \"a graphql or legacy id\",\n               required: false,\n               prepare: GraphQLHelpers.relay_or_legacy_id_prepare_func(\"Term\")\n      argument :sis_id, String, \"an id from the original SIS system\", required: false\n    end\n    def term(id: nil, sis_id: nil)\n      raise GraphQL::ExecutionError, \"Must specify exactly one of id or sisId\" if (id && sis_id) || !(id || sis_id)\n      return GraphQLNodeLoader.load(\"Term\", id, context) if id\n\n      GraphQLNodeLoader.load(\"TermBySis\", sis_id, context) if sis_id\n    end\n","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/app/graphql/types/query_type.rb#L142-L178","documentation":"The `submission` resolver supports three lookup shapes: by `id`, by (`assignment_id` + `user_id`), or by (`assignment_id` + `anonymous_id`). Any combination that matches none of these shapes raises this GraphQL::ExecutionError.","triggerScenarios":"Calling submission with: no arguments; only id + assignment_id; only assignment_id; assignment_id with neither user_id nor anonymous_id; or all of id/assignment_id/user_id (id takes precedence only when the pair shapes are otherwise complete — any non-matching shape errors).","commonSituations":"Anonymized courses where user_id is unavailable and the client forgets to supply anonymous_id; partial variable payloads after a refactor; passing user_id but forgetting assignment_id.","solutions":["Use id alone, or ensure assignment_id is paired with user_id, or assignment_id paired with anonymous_id.","For anonymous submissions, fetch the anonymous_id (e.g. from submissions connection) and pass assignment_id + anonymous_id.","Log the full argument set sent to identify which required pair is incomplete."],"exampleFix":"// before\nquery { submission(assignmentId: \"9\", userId: \"42\") { score } }\n// anonymous course: userId unknown\n// after\nquery { submission(assignmentId: \"9\", anonymousId: \"anon-8f3\") { score } }","handlingStrategy":"validation","validationCode":"function validSubmissionArgs(v) {\n  if (v.id) return true;\n  return Boolean(v.assignment_id) && Boolean(v.user_id || v.anonymous_id);\n}\nif (!validSubmissionArgs(vars)) throw new Error('submission needs id, or assignment_id+user_id, or assignment_id+anonymous_id');","typeGuard":"const canLoadSubmission = (v) => Boolean(v.id) || (Boolean(v.assignment_id) && Boolean(v.user_id ?? v.anonymous_id));","tryCatchPattern":"try { await gql(SUBMISSION_QUERY, vars); } catch (e) { if (e.message.startsWith('Must specify an id or an assignment_id')) { // complete the pair, e.g. resolve anonymousId then retry } else throw e; }","preventionTips":["In anonymized courses, resolve anonymous_id up front instead of user_id.","Always send assignment_id together with a student identifier; never alone.","Use id when you have it — it is the simplest valid shape."],"tags":["graphql","validation","arguments"],"backgroundTag":"missing-required-argument","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"}