Skip to content

Fix listTemplates NPE for External templates - #14340

Open
DaanHoogland wants to merge 1 commit into
4.22from
fix-npe-external-template-no-store
Open

DaanHoogland wants to merge 1 commit into
4.22from
fix-npe-external-template-no-store

Conversation

@DaanHoogland

Copy link
Copy Markdown
Contributor

Description

This PR...

fixes a NPE condition found during creating a new external hypervisor plugin.

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • Build/CI
  • Test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

How did you try to break this feature and the system with this change?

@codecov

codecov Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 70.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 18.37%. Comparing base (89a1f73) to head (1dc34ca).

Files with missing lines Patch % Lines
...tack/storage/datastore/db/TemplateDataStoreVO.java 33.33% 2 Missing ⚠️
...a/com/cloud/api/query/dao/TemplateJoinDaoImpl.java 85.71% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               4.22   #14340      +/-   ##
============================================
+ Coverage     18.34%   18.37%   +0.02%     
- Complexity    16679    16699      +20     
============================================
  Files          5940     5940              
  Lines        537840   537848       +8     
  Branches      65940    65940              
============================================
+ Hits          98668    98811     +143     
+ Misses       427946   427790     -156     
- Partials      11226    11247      +21     
Flag Coverage Δ
uitests 4.08% <ø> (ø)
unittests 19.46% <70.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sonarqubecloud

sonarqubecloud Bot commented Oct 7, 2026

Copy link
Copy Markdown

@DaanHoogland
DaanHoogland requested a balanced review from Copilot October 13, 2026 09:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

3 open findings
What changed in this PR

Fixes a NullPointerException encountered when listing template store entries for External/Baremetal templates that may have store_id = NULL.

Changes:

  • Add filtering for store-less TemplateDataStoreVO entries when listing template/ISO store mappings.
  • Introduce TemplateDataStoreVO.hasDataStore() to safely detect whether getDataStoreId() can be called.
  • Add unit tests validating store-less entries are skipped.
File Description
server/​src/​main/​java/​com/​cloud/​api/​query/​dao/​TemplateJoinDaoImpl.java Centralizes datastore listing and filters out store_id NULL rows to avoid NPEs downstream.
engine/​schema/​src/​main/​java/​org/​apache/​cloudstack/​storage/​datastore/​db/​TemplateDataStoreVO.java Adds hasDataStore() helper to safely detect store-less entries.
server/​src/​test/​java/​com/​cloud/​api/​query/​dao/​TemplateJoinDaoImplTest.java Adds tests ensuring store-less entries are excluded from results.

🧠 Review effort: Lite


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions

Copy link
Copy Markdown

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

@DaanHoogland DaanHoogland added this to the 4.22.3 milestone Dec 3, 2026
@DaanHoogland
DaanHoogland force-pushed the fix-npe-external-template-no-store branch from ed9571d to 1dc34ca Compare December 3, 2026 13:14
@DaanHoogland

Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@DaanHoogland a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 20281

@sonarqubecloud

sonarqubecloud Bot commented Dec 3, 2026

Copy link
Copy Markdown

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants