Environment
- nbxsync: 1.0.4
- NetBox: 5.2.13
- Zabbix: 7.4
Bug 1 — SyncMaintenceJob crashes immediately: missing self.zabbixserver
Traceback
AttributeError: 'SyncMaintenceJob' object has no attribute 'zabbixserver'
File "nbxsync/jobs/syncmaintenance.py", line 12, in run
if not self.zabbixserver.sync_enabled:
Root cause
SyncMaintenceJob.__init__ sets self.instance but never initializes self.zabbixserver, which is used immediately in run().
Fix
def __init__(self, **kwargs):
self.instance = kwargs.get('instance')
self.zabbixserver = self.instance.zabbixserver # missing line
Bug 2 — get_timeperiods() sends day parameter for all timeperiod types, rejected by Zabbix 7.x API
Traceback
zabbix_utils.exceptions.APIRequestError: Invalid params.
Invalid parameter "/1/timeperiods/1": unexpected parameter "day".
Root cause
In maintenancesync.py, the final block in get_timeperiods() unconditionally adds day or dayofweek to every timeperiod regardless of type:
if not timeperiod.dayofweek:
timeperiod_result['day'] = timeperiod.day
else:
...
The day parameter is only valid for MONTHLY timeperiods in the Zabbix API. For ONE_TIME periods (used by [AUTOMATIC] maintenances created via status mapping), Zabbix 7.x rejects it.
Fix
if timeperiod.timeperiod_type == ZabbixTimePeriodTypeChoices.MONTHLY:
if not timeperiod.dayofweek:
timeperiod_result['day'] = timeperiod.day
else:
timeperiod_result['dayofweek'] = 0
for x in timeperiod.dayofweek:
timeperiod_result['dayofweek'] |= x
Environment
Bug 1 —
SyncMaintenceJobcrashes immediately: missingself.zabbixserverTraceback
AttributeError: 'SyncMaintenceJob' object has no attribute 'zabbixserver'
File "nbxsync/jobs/syncmaintenance.py", line 12, in run
if not self.zabbixserver.sync_enabled:
Root cause
SyncMaintenceJob.__init__setsself.instancebut never initializesself.zabbixserver, which is used immediately inrun().Fix
Bug 2 —
get_timeperiods()sendsdayparameter for all timeperiod types, rejected by Zabbix 7.x APITraceback
Root cause
In
maintenancesync.py, the final block inget_timeperiods()unconditionally addsdayordayofweekto every timeperiod regardless of type:The
dayparameter is only valid forMONTHLYtimeperiods in the Zabbix API. ForONE_TIMEperiods (used by[AUTOMATIC]maintenances created via status mapping), Zabbix 7.x rejects it.Fix