{"record":{"id":"262bb4bf7c99608a","repo":"nodejs/node","slug":"s-s-did-you-forget-to-quote-the-callable-name","errorCode":null,"errorMessage":"%s (%s; did you forget to quote the callable name?)","messagePattern":"(.+?) \\((.+?); did you forget to quote the callable name\\?\\)","errorType":"exception","errorClass":"TemplateRuntimeError","httpStatus":null,"severity":"error","filePath":"tools/inspector_protocol/jinja2/environment.py","lineNumber":97,"sourceCode":"    \"\"\"Load the extensions from the list and bind it to the environment.\n    Returns a dict of instantiated environments.\n    \"\"\"\n    result = {}\n    for extension in extensions:\n        if isinstance(extension, string_types):\n            extension = import_string(extension)\n        result[extension.identifier] = extension(environment)\n    return result\n\n\ndef fail_for_missing_callable(string, name):\n    msg = string % name\n    if isinstance(name, Undefined):\n        try:\n            name._fail_with_undefined_error()\n        except Exception as e:\n            msg = '%s (%s; did you forget to quote the callable name?)' % (msg, e)\n    raise TemplateRuntimeError(msg)\n\n\ndef _environment_sanity_check(environment):\n    \"\"\"Perform a sanity check on the environment.\"\"\"\n    assert issubclass(environment.undefined, Undefined), 'undefined must ' \\\n        'be a subclass of undefined because filters depend on it.'\n    assert environment.block_start_string != \\\n        environment.variable_start_string != \\\n        environment.comment_start_string, 'block, variable and comment ' \\\n        'start strings must be different'\n    assert environment.newline_sequence in ('\\r', '\\r\\n', '\\n'), \\\n        'newline_sequence set to unknown line ending string.'\n    return environment\n\n\nclass Environment(object):\n    r\"\"\"The core component of Jinja is the `Environment`.  It contains\n    important shared variables like configuration, filters, tests,","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/tools/inspector_protocol/jinja2/environment.py#L79-L115","documentation":"Augmented message produced by fail_for_missing_callable (jinja2 environment.py) when a filter/test/global lookup fails AND the looked-up name is itself an Undefined. The base message names the missing callable; the parenthesized suffix is added because the usual cause is passing an undefined variable (which silently resolves to Undefined) instead of a string literal as the callable name.","triggerScenarios":"Calling env.call_filter / env.call_test with a name argument that is an Undefined (e.g. a typo'd variable or a missing context var) instead of a quoted string; template code that does `{{ x | somevar }}` where somevar is undefined and resolves to the filter-name slot.","commonSituations":"Dynamically selecting a filter by a variable that wasn't defined; refactoring that renamed a filter but left a call site referencing the old name through a variable; passing `name` as a Python variable holding Undefined from a broken context.","solutions":["Quote the callable name: pass `'upper'` not `upper` (or `env.call_filter('upper', value)`).","If the name must be dynamic, resolve and validate it from a known set before calling.","Check the second %s in the message — it reports the undefined error explaining which name was undefined."],"exampleFix":"# before\nf = maybe_missing_var      # undefined\nenv.call_filter(f, value)\n# after\nenv.call_filter('upper', value)","handlingStrategy":"validation","validationCode":"from jinja2 import Undefined\nKNOWN_FILTERS = {'upper', 'lower'}\ndef safe_call_filter(env, name, value):\n    if isinstance(name, Undefined) or name not in KNOWN_FILTERS:\n        raise ValueError('unknown or unquoted filter name: %r' % name)\n    return env.call_filter(name, value)","typeGuard":"from jinja2 import Undefined\ndef name_is_literal(name) -> bool:\n    return not isinstance(name, Undefined)","tryCatchPattern":"try:\n    env.call_filter(name, value)\nexcept Exception as e:\n    if 'did you forget to quote' in str(e):\n        env.call_filter('upper', value)   # use the intended literal name\n    else:\n        raise","preventionTips":["Quote filter/test/global names as string literals.","When choosing a filter dynamically, validate against a known set first.","Read the parenthesized cause in the message to find the undefined name."],"tags":["jinja2","filter","api","undefined"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}