{"record":{"id":"a4fb781cef6c7f6a","repo":"nodejs/node","slug":"missing-parameter-for-attribute-name","errorCode":null,"errorMessage":"Missing parameter for attribute name","messagePattern":"Missing parameter for attribute name","errorType":"exception","errorClass":"FilterArgumentError","httpStatus":null,"severity":"error","filePath":"tools/inspector_protocol/jinja2/filters.py","lineNumber":1110,"sourceCode":"        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:\n        try:\n            attr = args[2]\n        except LookupError:\n            raise FilterArgumentError('Missing parameter for attribute name')\n        transfunc = make_attrgetter(context.environment, attr)\n        off = 1\n    else:\n        off = 0\n        transfunc = lambda x: x\n\n    try:\n        name = args[2 + off]\n        args = args[3 + off:]\n        func = lambda item: context.environment.call_test(\n            name, item, args, kwargs)\n    except LookupError:\n        func = bool\n\n    return seq, lambda item: modfunc(func(transfunc(item)))\n\n\ndef select_or_reject(args, kwargs, modfunc, lookup_attr):","sourceCodeStart":1092,"sourceCodeEnd":1128,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/tools/inspector_protocol/jinja2/filters.py#L1092-L1128","documentation":"prepare_select_or_reject backs the selectattr/rejectattr filters. When lookup_attr is true (the *_attr variants), args[2] must be the attribute name to test against. If it is missing the LookupError is converted to FilterArgumentError('Missing parameter for attribute name').","triggerScenarios":"Calling {{ seq|selectattr }} or {{ seq|rejectattr }} without supplying the attribute name argument.","commonSituations":"Forgetting the attribute name when using selectattr/rejectattr; confusing them with select/reject (which need no attribute).","solutions":["Supply the attribute name: {{ users|selectattr('is_active') }}.","Optionally follow with a test name and args: {{ users|selectattr('age', 'gt', 18) }}.","If you meant to filter values directly (no attribute), use select/reject instead of selectattr/rejectattr."],"exampleFix":"{# before #}\n{{ users|selectattr }}\n\n{# after #}\n{{ users|selectattr('is_active') }}","handlingStrategy":"validation","validationCode":"def require_attr_name(attr_name):\n    if not attr_name:\n        raise ValueError('selectattr/rejectattr require an attribute name')\n    return attr_name","typeGuard":"def has_attr_name(attr_name) -> bool:\n    return isinstance(attr_name, str) and bool(attr_name)","tryCatchPattern":"from jinja2.exceptions import FilterArgumentError\ntry:\n    out = env.call_filter('selectattr', seq, args=(attr, test_name))\nexcept FilterArgumentError:\n    out = [x for x in seq if getattr(x, attr, None)]","preventionTips":["Distinguish select/reject (no attribute) from selectattr/rejectattr (attribute required).","Lint templates for bare selectattr/rejectattr."],"tags":["jinja2","filter","selectattr","validation"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}