code: def _format_json_error_messages(recs: list[dict]) -> str:
      # there could be many, condense
      msgs: Counter[str] = Counter()
      for r in recs:
          if r.get("success"):
              continue
          msg = "{}{}".format(
              " {}\n".format(r["note"]) if r.get("note") else "",
              "\n".join(r.get("error-messages", [])),
          )
          if "file" in r or "key" in r:
              msgs[msg] += 1
  
      if not msgs:
          return ""
  
      return "\n>{}".format(
          "\n> ".join(
              "{}{}".format(
                  m,
                  " [{} times]".format(n) if n > 1 else "",
              )
              for m, n in msgs.items()
          )
      )
  
file_path: datalad/datalad/runner/exception.py
imports: from __future__ import annotations
  import logging
  import os
  from collections import Counter
  from typing import Any, Optional
label_desc: Use image node_id 1 for calling a global function with example usage: _format_json_error_messages(recs) and returns: str, str