Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion core/src/main/java/cz/xtf/core/openshift/OpenShift.java
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,11 @@ public Build getBuild(String name) {
}

public Build getLatestBuild(String buildConfigName) {
long lastVersion = buildConfigs().withName(buildConfigName).get().getStatus().getLastVersion();
BuildConfig bc = buildConfigs().withName(buildConfigName).get();
if (bc == null) {
return null;
}
long lastVersion = bc.getStatus().getLastVersion();
Comment on lines +835 to +839
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): Guard against a null BuildConfig status before calling getLastVersion()

The null check on bc prevents one NPE, but bc.getStatus() itself can still be null (e.g., for a newly created/partially initialized BuildConfig), causing an NPE on getStatus().getLastVersion(). Please also guard against a null status (and optionally handle a 0/unset getLastVersion()) before building the name, or fail in a controlled way.

Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getLatestBuild still has a possible NPE: bc.getStatus() can be null (and in this codebase getLastVersion() is treated as nullable elsewhere), so bc.getStatus().getLastVersion() may crash even when bc is non-null. Consider returning null when bc.getStatus() is null and when getLastVersion() is null/0 (use Long instead of long) so waiters can retry gracefully.

Suggested change
long lastVersion = bc.getStatus().getLastVersion();
if (bc.getStatus() == null) {
return null;
}
Long lastVersion = bc.getStatus().getLastVersion();
if (lastVersion == null || lastVersion == 0L) {
return null;
}

Copilot uses AI. Check for mistakes.
return getBuild(buildConfigName + "-" + lastVersion);
}

Expand Down
Loading