Skip to content

TypeError: Call to a member function getTimestamp() on null in ConditionRenderer::assembleExtendedInfo() #174

Description

@maurito1990

Bug Report

Module version: 0.3.1 / 0.4.0 (present in both)

Description

ConditionRenderer::assembleExtendedInfo() throws a fatal TypeError when a condition has a null value for last_transition. This causes the Kubernetes web view to crash when
rendering conditions that have never transitioned.

Error

TypeError: Call to a member function getTimestamp() on null
in library/Kubernetes/View/ConditionRenderer.php:50

Steps to reproduce

  1. Have a Kubernetes resource (e.g. a Node or Pod) with a condition where lastTransitionTime is not set or is null in the cluster.
  2. Open the resource detail view in Icinga for Kubernetes Web.
  3. The page fails to render.

Root cause

In library/Kubernetes/View/ConditionRenderer.php, line 50:

// Current code — crashes when last_transition is null
$info->addHtml(new TimeAgo($item->last_transition->getTimestamp()));

last_transition can be null when a condition has no transition timestamp, but there is no null check before calling getTimestamp().

Fix

if ($item->last_transition !== null) {
    $info->addHtml(new TimeAgo($item->last_transition->getTimestamp()));
}

Environment

- Icinga for Kubernetes Web: 0.3.1 / 0.4.0
- Icinga for Kubernetes daemon: 0.3.0
- IcingaWeb2: 2.12.x
- Kubernetes: GKE

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions