Describe the bug
The $explain_COLUMN directive in report configuration does not produce a tooltip when the same column also has a $name_COLUMN override. This is because make_table_headers in python/nav/report/report.py overwrites the field name with the display name before looking up the explanation, and the explain dict is keyed by the original SQL field name.
Columns that use $explain_ without $name_ work fine. Currently, 13 out of 24 $explain_ directives in report.conf are affected (those that also have a $name_ on the same field).
The bug has been present since the original 2003 code and has persisted through every refactor since.
To Reproduce
- Go to any report where a column has both
$explain_ and $name_, e.g. /report/swport (the to_netboxid column has both)
- Hover over the column header
- No tooltip appears
Compare with a column that only has $explain_ (no $name_), e.g. the "control" column in /report/topology_candidates — this one correctly shows a tooltip.
Expected behavior
Hovering over a column header should show the $explain_ text as a tooltip regardless of whether $name_ is also set.
Additional context
The relevant code in make_table_headers:
title = names.get(title, title) # title is now the display name
explanation = explain.get(title, "") # lookup fails: explain is keyed by SQL field name
The fix is to look up the explanation before overriding the title:
explanation = explain.get(title, "") # title is still the SQL field name
title = names.get(title, title)
Describe the bug
The
$explain_COLUMNdirective in report configuration does not produce a tooltip when the same column also has a$name_COLUMNoverride. This is becausemake_table_headersinpython/nav/report/report.pyoverwrites the field name with the display name before looking up the explanation, and theexplaindict is keyed by the original SQL field name.Columns that use
$explain_without$name_work fine. Currently, 13 out of 24$explain_directives inreport.confare affected (those that also have a$name_on the same field).The bug has been present since the original 2003 code and has persisted through every refactor since.
To Reproduce
$explain_and$name_, e.g./report/swport(theto_netboxidcolumn has both)Compare with a column that only has
$explain_(no$name_), e.g. the "control" column in/report/topology_candidates— this one correctly shows a tooltip.Expected behavior
Hovering over a column header should show the
$explain_text as a tooltip regardless of whether$name_is also set.Additional context
The relevant code in
make_table_headers:The fix is to look up the explanation before overriding the title: