{"record":{"id":"b084bc5c6235b8cd","repo":"emberjs/ember.js","slug":"you-must-pass-a-function-as-the-second-argument-to","errorCode":null,"errorMessage":"You must pass a function as the second argument to the `on` modifier; you passed ${userProvidedCallback === null ? 'null' : typeof userProvidedCallback}. While rendering:\\n\\n${args.positional[1]?.debugLabel ?? '(unknown)'} on ${selector}","messagePattern":"You must pass a function as the second argument to the `on` modifier; you passed (.+?)\\. While rendering:\\\\n\\\\n(.+?) on (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/@glimmer/runtime/lib/modifiers/on.ts","lineNumber":96,"sourceCode":"    if (DEBUG && !eventName) {\n      throw new Error(\n        `You must pass a valid DOM event name as the first argument to the \\`on\\` modifier on ${selector}`\n      );\n    }\n\n    let arg1 = args.positional[1];\n    let userProvidedCallback = check(\n      arg1 ? valueForRef(arg1) : undefined,\n      CheckFunction,\n      (actual) => {\n        return `You must pass a function as the second argument to the \\`on\\` modifier; you passed ${\n          actual === null ? 'null' : typeof actual\n        }. While rendering:\\n\\n${args.positional[1]?.debugLabel ?? `{unlabeled value}`}`;\n      }\n    ) as EventListener;\n\n    if (DEBUG && typeof userProvidedCallback !== 'function') {\n      throw new Error(\n        `You must pass a function as the second argument to the \\`on\\` modifier; you passed ${\n          userProvidedCallback === null ? 'null' : typeof userProvidedCallback\n        }. While rendering:\\n\\n${args.positional[1]?.debugLabel ?? '(unknown)'} on ${selector}`\n      );\n    }\n\n    if (DEBUG && args.positional.length !== 2) {\n      throw new Error(\n        `You can only pass two positional arguments (event name and callback) to the \\`on\\` modifier, but you provided ${args.positional.length}. Consider using the \\`fn\\` helper to provide additional arguments to the \\`on\\` callback on ${selector}`\n      );\n    }\n\n    let once: boolean | undefined = undefined;\n    let passive: boolean | undefined = undefined;\n    let capture: boolean | undefined = undefined;\n\n    if (DEBUG) {\n      let { once: _once, passive: _passive, capture: _capture, ...extra } = reifyNamed(args.named);","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/emberjs/ember.js/blob/26f97246a8bf2e28edf26ac3093da2e86c04ffc5/packages/@glimmer/runtime/lib/modifiers/on.ts#L78-L114","documentation":"Error \"You must pass a function as the second argument to the `on` modifier; you passed ${userProvidedCallback === null ? 'null' : typeof userProvidedCallback}. While rendering:\\n\\n${args.positional[1]?.debugLabel ?? '(unknown)'} on ${selector}\" thrown in emberjs/ember.js.","triggerScenarios":"Thrown at packages/@glimmer/runtime/lib/modifiers/on.ts:96 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"26f97246a8bf2e28edf26ac3093da2e86c04ffc5","analyzedAt":"2026-09-01T05:01:28.182Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}