Repository: librenms/librenms (language: php)

Issue:
JunOS Transceiver support is erroring
### The problem

We're getting lots of errors related to the tranceiver module on junos devices since that feature was introduced

```
Error discovering transceivers module for 172.30.40.22. TypeError: LibreNMS\OS\Junos::findTransceiverEntityByPortName(): Argument #2 ($ifName) must be of type string, null given, called in /opt/librenms/LibreNMS/OS/Junos.php on line 304 and defined in /opt/librenms/LibreNMS/OS/Junos.php:337
Stack trace:
#0 /opt/librenms/LibreNMS/OS/Junos.php(304): LibreNMS\OS\Junos->findTransceiverEntityByPortName()
#1 [internal function]: LibreNMS\OS\Junos->LibreNMS\OS\{closure}()
#2 /opt/librenms/LibreNMS/Data/Source/SnmpResponse.php(270): call_user_func()
#3 /opt/librenms/LibreNMS/OS/Junos.php(303): LibreNMS\Data\Source\SnmpResponse->mapTable()
#4 /opt/librenms/LibreNMS/Modules/Transceivers.php(60): LibreNMS\OS\Junos->discoverTransceivers()
#5 /opt/librenms/includes/discovery/transceivers.inc.php(32): LibreNMS\Modules\Transceivers->discover()
#6 /opt/librenms/includes/discovery/functions.inc.php(170): include('...')
#7 /opt/librenms/discovery.php(108): discover_device()
#8 {main}  
LibreNMS\OS\Junos::findTransceiverEntityByPortName(): Argument #2 ($ifName) must be of type string, null given, called in /opt/librenms/LibreNMS/OS/Junos.php on line 304 {"exception":"[object] (TypeError(code: 0): LibreNMS\\OS\\Junos::findTransceiverEntityByPortName(): Argument #2 ($ifName) must be of type string, null given, called in /opt/librenms/LibreNMS/OS/Junos.php on line 304 at /opt/librenms/LibreNMS/OS/Junos.php:337)"} 
```

### Output of ./validate.php

```txt
librenms@librenms:~$ ./validate.php 
===========================================
Component | Version
--------- | -------
LibreNMS  | 24.12.0-11-gb9472e9a7 (2024-12-18T00:15:53+00:00)
DB Schema | 2024_11_22_135845_alert_log_refactor_indexes (310)
PHP       | 8.3.15
Python    | 3.11.2
Database  | MariaDB 10.11.6-MariaDB-0+deb12u1
RRDTool   | 1.7.2
SNMP      | 5.9.3
===========================================

[OK]    Composer Version: 2.8.4
[OK]    Dependencies up-to-date.
[OK]    Database connection successful
[OK]    Database connection successful
[OK]    Database Schema is current
[OK]    SQL Server meets minimum requirements
[OK]    lower_case_table_names is enabled
[OK]    MySQL engine is optimal
[OK]    Database and column collations are correct
[OK]    Database schema correct
[OK]    MySQL and PHP time match
[OK]    Active pollers found
[OK]    Dispatcher Service is enabled
[OK]    Locks are functional
[OK]    Python wrapper cron entry is not present
[OK]    Redis is unavailable
[OK]    rrdtool version ok
[OK]    Connected to rrdcached
librenms@librenms:~$ 
```
```


### What was the last working version of LibreNMS?

_No response_

### Anything in the logs that might be useful for us?

_No response_


Discussion / hints:

Fix patch:
diff --git a/LibreNMS/OS/Junos.php b/LibreNMS/OS/Junos.php
index 057c4b49c5ab..9e46b537ae14 100644
--- a/LibreNMS/OS/Junos.php
+++ b/LibreNMS/OS/Junos.php
@@ -334,7 +334,7 @@ public function discoverTransceivers(): Collection
             });
     }
 
-    private function findTransceiverEntityByPortName(array $entPhysical, string $ifName): array
+    private function findTransceiverEntityByPortName(array $entPhysical, ?string $ifName): array
     {
         if (preg_match('#-(\d+/\d+/\d+)#', $ifName, $matches)) {
             $expected_tail = ' @ ' . $matches[1];


Test patch: