Skip to content

Commit a4146bf

Browse files
committed
19859 FIX printer_supply: skip nameless supplies during discovery
Service discovery for the printer_supply check crashed with TypeError: 'item' must be a non empty string or ommited entirely, got '' when a printer reported a supply entry without a name. Nameless supplies are now skipped instead of aborting discovery for the whole device. Crash-Group-ID: 3957 Jira: CMK-33989 Change-Id: I6830aba17ccb4b0a650d1816f71d6a4d18e51a3d
1 parent 434ca37 commit a4146bf

3 files changed

Lines changed: 23 additions & 4 deletions

File tree

.werks/19859.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[//]: # (werk v3)
2+
# printer_supply: skip nameless supplies during discovery
3+
4+
key | value
5+
---------- | ---
6+
date | 2026-04-23T09:09:51.558507+00:00
7+
version | 2.6.0b1
8+
class | fix
9+
edition | community
10+
component | checks
11+
level | 1
12+
compatible | yes
13+
14+
Service discovery for the `printer_supply` check crashed with `TypeError:
15+
'item' must be a non empty string or ommited entirely, got ''` when a
16+
printer reported a supply entry without a name.
17+
18+
Nameless supplies are now skipped instead of aborting discovery for the
19+
whole device.

cmk/plugins/collection/agent_based/printer_supply.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,10 @@ def parse_printer_supply(string_table: Sequence[StringTable]) -> Section:
229229

230230
def discovery_printer_supply(section: Section) -> DiscoveryResult:
231231
for key in section.keys():
232+
# Some printers expose supply entries without a name; Service(item="")
233+
# is rejected by the v2 API, so those entries are skipped.
234+
if not key:
235+
continue
232236
yield Service(item=key)
233237

234238

tests/unit/cmk/plugins/collection/agent_based/test_printer_supply.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,6 @@ def test_inventory_printer_supply(
8787
assert list(result) == expected_result
8888

8989

90-
@pytest.mark.xfail(
91-
strict=True,
92-
reason="Crash group 3957: empty supply name crashes Service(item='')",
93-
)
9490
def test_discovery_printer_supply_skips_empty_supply_name() -> None:
9591
info: list[StringTable] = [
9692
[["1.4", "black"]],

0 commit comments

Comments
 (0)