Enhance user-friendly error messaging for UDI limit (50) in playbook#445
Merged
madhansansel merged 5 commits intocisco-en-programmability:mainfrom Apr 29, 2026
Merged
Conversation
| if "9003" in error_str or "max supported number" in error_str or "UDIs have hit max" in error_str: | ||
| self.msg = ( | ||
| "Failed to create the user-defined issue '{name}'. " | ||
| "The system has reached the maximum limit of 50 custom issues. " |
Collaborator
There was a problem hiding this comment.
Can we define the value 50 in the class itself?
MAX_CUSTOM_ISSUES = 50
UDI_LIMIT_ERROR_PATTERNS = ("9003", "max supported number", "UDIs have hit max")
except Exception as msg:
error_str = str(msg)
if any(pattern in error_str for pattern in self.UDI_LIMIT_ERROR_PATTERNS):
self.msg = (
"Failed to create the user-defined issue '{name}' in Cisco Catalyst Center. "
"The system has reached the maximum limit of {limit} custom issues. "
"Please delete one or more existing issues before creating new ones."
).format(name=issue.get("name"), limit=self.MAX_CUSTOM_ISSUES)
self.log(self.msg, "WARNING")
else:
self.msg = (
"Exception occurred while creating the user-defined issue "
"in Cisco Catalyst Center: {msg}"
).format(msg=msg)
self.log(error_str, "ERROR")
| requirements: | ||
| - dnacentersdk >= 2.8.6 | ||
| - python >= 3.9 | ||
| notes: |
Collaborator
There was a problem hiding this comment.
- The maximum number of user-defined (custom) issue definitions
supported by Cisco Catalyst Center is 50. Attempting to create
more will result in an error.
| @@ -1 +1 @@ | |||
| #!/usr/bin/python | |||
Collaborator
There was a problem hiding this comment.
Do we need to update the Unit test cases?
import pytest
from unittest.mock import MagicMock, patch
def test_create_issue_udi_limit_error_returns_friendly_message():
"""Verify user-friendly message when UDI limit is reached."""
# Setup module mock
module = MagicMock()
instance = create_assurance_settings_instance(module)
instance.dnac._exec = MagicMock(
side_effect=Exception("Error 9003: UDIs have hit max supported number")
)
instance.set_operation_result = MagicMock()
issue = {"name": "Test Issue", "rules": [], "is_enabled": True,
"priority": "P1", "is_notification_enabled": False,
"description": "desc"}
# Call create with one issue that will hit the limit
# Assert self.msg contains "maximum limit of 50"
assert "maximum limit of 50" in instance.msg
def test_create_issue_generic_error_preserves_original_message():
"""Verify generic errors are not swallowed by the UDI limit handler."""
module = MagicMock()
instance = create_assurance_settings_instance(module)
instance.dnac._exec = MagicMock(
side_effect=Exception("Connection timeout")
)
instance.set_operation_result = MagicMock()
# Assert self.msg contains "Connection timeout"
assert "Connection timeout" in instance.msg
madhansansel
approved these changes
Apr 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type of Change
Description
This PR includes the bug fix of [Assurance][iac3.0]: Playbook throws unclear error when user-defined issue creation exceeds limit of 50.
Summary:
The earlier unclear error ('list' object has no attribute 'get') is no longer observed, indicating improvement in error handling. Currently, the playbook returns the API error message, which correctly reflects that the maximum limit of 50 UDIs has been reached. However, the message is still not user-friendly. The submitter requests further enhancement to format the error into a clearer, more actionable message for better user experience.
Testing Done:
Test cases covered: [Mention test case IDs or brief points]
Checklist
Ansible Best Practices
ansible-vaultor environment variables)Documentation
Screenshots (if applicable)
Notes to Reviewers