Skip to content

generator: reject index types the collector cannot render#1653

Open
lukeod wants to merge 1 commit into
prometheus:mainfrom
lukeod:index-type-validation
Open

generator: reject index types the collector cannot render#1653
lukeod wants to merge 1 commit into
prometheus:mainfrom
lukeod:index-type-validation

Conversation

@lukeod

@lukeod lukeod commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

The generator emits index types the collector cannot render as labels (DateAndTime, Bits, etc). indexOidsAsString panics on them in the collect goroutine, which exits the whole exporter process - one row in an affected table is enough. This is reachable from standard MIBs: ALARM-MIB::alarmActiveTable (RFC 3877) is indexed by alarmActiveDateAndTime, so generating a module for it produces a config that crashes the exporter on the first scrape of a populated table.

The proposed approach:

  • Drop tables whose index type is not renderable, with a warning, matching the existing unhandled-type behavior.
  • Fail generation when a chained lookup promotes a non-renderable type to an index.
  • The allowlist is config.RenderableIndexTypes; a collector test asserts every entry renders without panic. It lives in config, which the generator and collector both already import. Integer/Integer32 are listed for hand-written configs (the generator never emits them as index types)

No module in the shipped snmp.yml carries an affected index type, so regenerating it drops nothing. The Bits test expectation is updated: the previous expected output encoded a config that panics the exporter. A type: OctetString override keeps a dropped table (renders as hex). Some rejected types could reasonably be rendered in future (e.g. DateAndTime as a timestamp label); adding the collector case and listing the type re-admits those tables. Hardening the collector against such configs already in the field (hand-written or from older generators) is another possible follow-up.

Part of the generator display_hint work for #1610, alongside #1646 and #1648.

Signed-off-by: lukeod <l.odonnell11@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant