in connectors/keyvault.py [0:0]
def generate_valid_secret_name(base_name: str) -> str:
"""
Generate a valid secret name that contains only alphanumeric characters and dashes.
Args:
base_name (str): The base name to convert into a valid secret name.
Returns:
str: A sanitized secret name with only valid characters.
"""
# Replace any non-alphanumeric characters with dashes
sanitized_name = re.sub(r'[^a-zA-Z0-9-]', '-', base_name)
# Ensure it does not start or end with a dash and limit its length
sanitized_name = sanitized_name.strip('-')[:63] # Max length for Azure Key Vault secret names is 63
return sanitized_name or "default-secret"