Skip to content

framework,api,server,ui: improve error messaging - #12336

Open
shwstppr wants to merge 33 commits into
apache:4.22from
shapeblue:improve-error-messages
Open

shwstppr wants to merge 33 commits into
apache:4.22from
shapeblue:improve-error-messages

Conversation

@shwstppr

@shwstppr shwstppr commented Dec 24, 2025 •

Copy link
Copy Markdown
Contributor

Description

Framework-level improvements for contextual and localized API error messages

Design spec: Error Message Consistency, Customization, and Localization Framework

Documentation PR: apache/cloudstack-documentation#684

Developed focused documentation is also added at api/src/main/java/org/apache/cloudstack/error/README.md

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):

Refined error message with additional context for admin
image

User facing error, with localization
image

Example API response

{
    "deployvirtualmachineresponse": {
        "uuidList": [],
        "errorcode": 535,
        "cserrorcode": 9999,
        "errortext": "Unable to deploy Instance because allocating 1 more Instance would exceed the Account limits. Current: 2, Reserved: 0, Limit: 2. Release unused resources, then retry.",
        "errortextkey": "vm.deploy.resourcelimit.exceeded.account",
        "errormetadata": {
            "resourceRequested": "1",
            "resourceTypeDisplay": "Instance",
            "resourceOwnerType": "Account",
            "resourceAmount": "2",
            "resourceReserved": "0",
            "resourceLimit": "2"
        }
    }
}

How Has This Been Tested?

End-to-end testing and the following smoke test,

[root@qa1-improve-err-88bf966b-kvm-mgmt1 marvin]# nosetests --with-xunit --xunit-file=results.xml --with-marvin --marvin-config=./marvin.cfg -s -a tags=advanced --hypervisor=KVM tests/smoke/test_error_message_framework.py 
/usr/local/lib/python3.6/site-packages/paramiko/transport.py:32: CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python core team. Therefore, support for it is deprecated in cryptography. The next release of cryptography will remove support for Python 3.6.
  from cryptography.hazmat.backends import default_backend

==== Marvin Init Started ====

=== Marvin Parse Config Successful ===

=== Marvin Setting TestData Successful===

==== Log Folder Path: /tmp/MarvinLogs/Sep_18_2026_04_59_46_OYCP7L All logs will be available here ====

=== Marvin Init Logging Successful===

==== Marvin Init Successful ====
=== TestName: test_01_runtime_error_message_override_for_regular_user | Status : SUCCESS ===

=== TestName: test_02_runtime_error_message_override_for_admin | Status : SUCCESS ===

=== Final results are now copied to: /tmp//MarvinLogs/test_error_message_framework_DBR9CT ===

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

@codecov

codecov Bot commented Dec 24, 2025 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 63.25648% with 255 lines in your changes missing coverage. Please review.
✅ Project coverage is 18.41%. Comparing base (c4c9731) to head (069528e).
⚠️ Report is 9 commits behind head on 4.22.

Files with missing lines Patch % Lines
...n/java/com/cloud/vm/VirtualMachineManagerImpl.java 11.72% 128 Missing ⚠️
...n/java/org/apache/cloudstack/error/Exceptions.java 57.31% 30 Missing and 5 partials ⚠️
...he/cloudstack/context/ResponseMessageResolver.java 86.61% 17 Missing and 17 partials ⚠️
...loudstack/api/command/user/vm/BaseDeployVMCmd.java 52.38% 20 Missing ⚠️
.../com/cloud/api/response/ApiResponseSerializer.java 0.00% 16 Missing ⚠️
...udstack/engine/cloud/entity/api/db/VMEntityVO.java 0.00% 4 Missing ⚠️
...he/cloudstack/api/command/user/vm/UpdateVMCmd.java 0.00% 3 Missing ⚠️
...rc/main/java/com/cloud/configuration/Resource.java 90.90% 2 Missing ⚠️
...ava/org/apache/cloudstack/context/CallContext.java 93.10% 0 Missing and 2 partials ⚠️
...ine/cloud/entity/api/VirtualMachineEntityImpl.java 0.00% 2 Missing ⚠️
... and 7 more
Additional details and impacted files
@@             Coverage Diff              @@
##               4.22   #12336      +/-   ##
============================================
+ Coverage     18.31%   18.41%   +0.10%     
- Complexity    16633    16788     +155     
============================================
  Files          5939     5941       +2     
  Lines        537748   538274     +526     
  Branches      65924    66005      +81     
============================================
+ Hits          98472    99140     +668     
+ Misses       428070   427868     -202     
- Partials      11206    11266      +60     
Flag Coverage Δ
uitests 4.09% <ø> (+0.01%) ⬆️
unittests 19.51% <63.25%> (+0.11%) ⬆️

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.

@shwstppr
shwstppr force-pushed the improve-error-messages branch from 86379b7 to c938bd1 Compare December 24, 2025 11:55
@shwstppr shwstppr closed this Jan 6, 2026
@shwstppr shwstppr reopened this Jan 6, 2026
@apache apache deleted a comment from blueorangutan Jan 6, 2026
@apache apache deleted a comment from blueorangutan Jan 6, 2026
@apache apache deleted a comment from blueorangutan Jan 6, 2026
@apache apache deleted a comment from blueorangutan Jan 6, 2026
@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.

@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.

@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.

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

4 open issues
10 resolved since last review

Review effort: Lite

Comment thread scripts/util/error_messages_tool.py Resolved
Comment thread scripts/util/error_messages_tool.py Resolved
@blueorangutan

Copy link
Copy Markdown

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

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
@shwstppr

Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@shwstppr 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 19618

@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.

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
@shwstppr

Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@shwstppr 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 19834

@vladimirpetrov

Copy link
Copy Markdown
Contributor

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

@vladimirpetrov a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@vladimirpetrov vladimirpetrov 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.

LGTM based on manual testing, let's wait for the smoke tests to finish.

@blueorangutan

Copy link
Copy Markdown

[SF] Trillian test result (tid-17347)
Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
Total time taken: 51590 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr12336-t17347-kvm-ol8.zip
Smoke tests completed. 150 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File

@harikrishna-patnala

Copy link
Copy Markdown
Member

This is PR is all good, but please dont merge it until 4.22.2 release is out

@RosiKyu

RosiKyu commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

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

4 open issues

10 resolved since last review

Review effort: Lite

@shwstppr , could you please have a look at the Copilot comments and check if any of these need to be addressed? Thank you!

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.

Comment on lines +833 to +834
text = _load_text(args.file)
entries = parse_entries(text)
Comment on lines +51 to +53
@SerializedName("errormetadata")
@Param(description = "the metadata associated with this error", since = "4.22.2")
private Map<String, String> errorMetadata;
Comment on lines +281 to +282
if (!isAdmin) {
result = result.replaceAll("\\bid:\\s*\\d+", "").trim();
Comment on lines +456 to +457
Map<String, Object> combinedMetadata = getCombinedMetadataFromErrorTemplate(template, map,
true);
Comment on lines +110 to +112
if (object instanceof CloudRuntimeException) {
Exceptions.normalizeMetadata((CloudRuntimeException)object);
}
Comment thread packaging/el8/cloud.spec

# Plugin-specific error-messages-*.json files are runtime/environment-specific only and are never
# bundled here; an operator or plugin drops them alongside error-messages.json after install.
cp client/target/conf/messages/error-messages.json ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/management/messages/error-messages.json
Comment thread scripts/util/error_messages_tool.py Outdated
print(new_text)
return 0

if new_text == text:
Comment on lines +139 to +149
self._write_error_messages_file(json.dumps(data, indent=4))

# diagnostic: tells a write/targeting bug apart from a reload bug if this ever fails
readback = self._read_error_messages_file()
self.assertIsNotNone(readback, "Could not read back %s right after writing it" % self.ERROR_MESSAGES_PATH)
self.assertIn(
self.base_marker, readback,
"The override was not present when reading %s back immediately after writing it" % self.ERROR_MESSAGES_PATH
)

time.sleep(self.SETTLE_DELAY_SECONDS)
Comment thread ui/src/utils/plugins.js Outdated
}
if (params && params.constructor === Object) {
for (const paramKey in params) {
localeMsg = localeMsg.replaceAll(`{{${paramKey}}}`, params[paramKey])
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>

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

Status: Backlog

Development

Successfully merging this pull request may close these issues.

9 participants