Skip to content

Commit 16f4114

Browse files
committed
Tweaks to displayed credential info for edge cases
Signed-off-by: Emiliano Suñé <emiliano.sune@gmail.com>
1 parent f72b866 commit 16f4114

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

server/vcr-server/agent_webhooks/management/commands/delete_credential_type.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,25 @@ def _check_and_confirm_deletion(self, *args, **options):
8080
self.stdout.write("\n" + "="*60)
8181
self.stdout.write("CREDENTIAL TYPE DELETION CONFIRMATION")
8282
self.stdout.write("="*60)
83-
self.stdout.write(f"Credential Type: {credential_type.description}")
83+
84+
# Use description if available, otherwise fall back to raw_data.type
85+
display_name = credential_type.description
86+
if (not display_name and hasattr(credential_type, 'raw_data') and
87+
credential_type.raw_data):
88+
try:
89+
import json
90+
91+
# Parse JSON string to get the type attribute
92+
raw_data_obj = json.loads(credential_type.raw_data)
93+
display_name = raw_data_obj.get('type')
94+
except (json.JSONDecodeError, AttributeError, TypeError, KeyError):
95+
display_name = None
96+
97+
# Final fallback to ID if no display name found
98+
if not display_name:
99+
display_name = f"Credential Type ID {credential_type_id}"
100+
101+
self.stdout.write(f"Credential Type: {display_name}")
84102
self.stdout.write(f"ID: {credential_type_id}")
85103
self.stdout.write(
86104
f"Found {credentials.count()} credentials to delete"

0 commit comments

Comments
 (0)