from typing import List
from typing import Dict
from typing import Set


def get_unique_affected_entity_ids(security_problems: List[Dict]) -> Set[str]:
    """Extract all unique affected entity IDs from a list of security problems.
    :param security_problems: the security problems, parsed from JSON to Dicts of Dicts
    :return: the set of unique affected entity IDs across all provided security problems
    """
    if not all(['affectedEntities' in x for x in security_problems]):
        raise ValueError("Security problems need to contain attribute 'affectedEntities'")
    return {entry for sp in security_problems for entry in sp['affectedEntities']}