Skip to content

[BUG] Report $explain_ tooltip broken when column also has $name_ override #3876

@lunkwill42

Description

@lunkwill42

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

  1. Go to any report where a column has both $explain_ and $name_, e.g. /report/swport (the to_netboxid column has both)
  2. Hover over the column header
  3. 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)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions