{"record":{"id":"c9ea00e80a6d3e68","repo":"nodejs/node","slug":"unexpected-keyword-argument-r","errorCode":null,"errorMessage":"Unexpected keyword argument %r","messagePattern":"Unexpected keyword argument %r","errorType":"exception","errorClass":"FilterArgumentError","httpStatus":null,"severity":"error","filePath":"tools/inspector_protocol/jinja2/filters.py","lineNumber":1088,"sourceCode":"    .. versionadded:: 2.9\n    \"\"\"\n    policies = eval_ctx.environment.policies\n    dumper = policies['json.dumps_function']\n    options = policies['json.dumps_kwargs']\n    if indent is not None:\n        options = dict(options)\n        options['indent'] = indent\n    return htmlsafe_json_dumps(value, dumper=dumper, **options)\n\n\ndef prepare_map(args, kwargs):\n    context = args[0]\n    seq = args[1]\n\n    if len(args) == 2 and 'attribute' in kwargs:\n        attribute = kwargs.pop('attribute')\n        if kwargs:\n            raise FilterArgumentError('Unexpected keyword argument %r' %\n                next(iter(kwargs)))\n        func = make_attrgetter(context.environment, attribute)\n    else:\n        try:\n            name = args[2]\n            args = args[3:]\n        except LookupError:\n            raise FilterArgumentError('map requires a filter argument')\n        func = lambda item: context.environment.call_filter(\n            name, item, args, kwargs, context=context)\n\n    return seq, func\n\n\ndef prepare_select_or_reject(args, kwargs, modfunc, lookup_attr):\n    context = args[0]\n    seq = args[1]\n    if lookup_attr:","sourceCodeStart":1070,"sourceCodeEnd":1106,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/tools/inspector_protocol/jinja2/filters.py#L1070-L1106","documentation":"prepare_map parses arguments for the map filter. When called as {{ seq|map(attribute='x') }}, the only accepted keyword is 'attribute'. If 'attribute' was already consumed and any extra keyword arguments remain, they are unrecognized and Jinja2 raises FilterArgumentError naming the first leftover kwarg.","triggerScenarios":"Calling {{ seq|map(attribute='name', default='x') }} or any map invocation that passes 'attribute' plus one or more additional keyword arguments.","commonSituations":"Assuming map(attribute=...) accepts filter options like 'default'; typos in the keyword name (e.g. attr=, field=).","solutions":["Pass only the 'attribute' keyword to the attribute form: {{ seq|map(attribute='name') }}.","If you need a transformation with options, use the filter-name form {{ seq|map('filter_name', *args) }} or chain filters after map."],"exampleFix":"{# before #}\n{{ users|map(attribute='name', default='anon') }}\n\n{# after #}\n{{ users|map(attribute='name') }}","handlingStrategy":"validation","validationCode":"def validate_map_kwargs(kwargs):\n    extra = set(kwargs) - {'attribute'}\n    if extra:\n        raise ValueError('map: unexpected keyword argument(s) %r' % (sorted(extra),))","typeGuard":"def is_map_kwarg(name: str) -> bool:\n    return name == 'attribute'","tryCatchPattern":"from jinja2.exceptions import FilterArgumentError\ntry:\n    out = env.call_filter('map', seq, args=(), kwargs=kwargs)\nexcept FilterArgumentError:\n    out = env.call_filter('map', seq, args=(), kwargs={'attribute': kwargs['attribute']})","preventionTips":["When building map calls programmatically, filter kwargs to just 'attribute'.","Document that map(attribute=...) takes no other options."],"tags":["jinja2","filter","map","validation"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}