import yaml
import re
import json

with open('recording-rules-new.yaml', 'r') as prom_rules_file:
    prom_rules = yaml.safe_load(prom_rules_file.read())

from collections import defaultdict
obj = defaultdict(list)

with open('dashboard.json', 'r') as dashboard_file:
    doc = json.load(dashboard_file)
    panels = doc['panels']
    for panel in panels:
        if "title" in panel:
            title = panel["title"]
        if "targets" in panel:
            for target in panel["targets"]:
                obj[title].append(target["expr"])
        elif "panels" in panel:
            for inner_panel in panel["panels"]:
                if "targets" in inner_panel:
                    for inner_target in inner_panel["targets"]:
                        obj[inner_panel["title"]].append(inner_target["expr"])

find erors in this code