def _normalize_frame()

in sapp/pipeline/mariana_trench_parser.py [0:0]


    def _normalize_frame(frame: Dict[str, Any], method: Method) -> List[Dict[str, Any]]:
        if "canonical_names" not in frame:
            return [frame]

        frames = []
        # Expected format: "canonical_names": [ { "instantiated": "<name>" }, ... ]
        # Canonical names are used for CRTEX only, and are expected to be the callee
        # name where traces are concerened. Each instantiated name maps to one frame.
        for canonical_name in frame["canonical_names"]:
            if (
                "instantiated" not in canonical_name
                and SOURCE_VIA_TYPE_PLACEHOLDER not in canonical_name["template"]
            ):
                # Uninstantiated canonical names are user-defined CRTEX leaves
                # They do not show up as a frame in the UI.
                continue

            frame_copy = frame.copy()  # Shallow copy is ok, only "callee" is different.
            if "instantiated" in canonical_name:
                callee = canonical_name["instantiated"]
            else:
                callee = canonical_name["template"].replace(
                    PROGRAMMATIC_LEAF_NAME_PLACEHOLDER, method.name
                )
                # If the canonical name is uninstantiated, the canonical port will be
                # uninstantiated too, so we fill it in here.
                frame_copy["callee_port"] = "Anchor." + frame.get(
                    "caller_port",
                    "Return",  # Frames within the issue won't have a caller port,
                    # and we know that only Return sinks will reach this logic
                    # right now, so the default is return
                )

            frame_copy["callee"] = callee
            frames.append(frame_copy)

        return frames