# Buggy code
def merge_service_dicts(base, override, version):
    md = MergeDict(base, override)

    md.merge_mapping("environment", parse_environment)
    md.merge_mapping("labels", parse_labels)
    md.merge_mapping("ulimits", parse_ulimits)
    md.merge_mapping("networks", parse_networks)
    md.merge_sequence("links", ServiceLink.parse)

    for field in ["volumes", "devices"]:
        md.merge_field(field, merge_path_mappings)

    for field in [
        "ports",
        "cap_add",
        "cap_drop",
        "expose",
        "external_links",
        "security_opt",
        "volumes_from",
        "depends_on",
    ]:
        md.merge_field(field, merge_unique_items_lists, default=[])

    for field in ["dns", "dns_search", "env_file", "tmpfs"]:
        md.merge_field(field, merge_list_or_string)

    md.merge_field("logging", merge_logging)

    for field in set(ALLOWED_KEYS) - set(md):
        md.merge_scalar(field)

    if version == V1:
        legacy_v1_merge_image_or_build(md, base, override)
    elif md.needs_merge("build"):
        md["build"] = merge_build(md, base, override)

    return dict(md)


# Traceback (AttributeError)
docker-compose up
Traceback (most recent call last):
File "<string>", line 3, in <module>
File "compose/cli/main.py", line 65, in main
File "compose/cli/main.py", line 114, in perform_command
File "compose/cli/command.py", line 36, in project_from_options
File "compose/cli/command.py", line 103, in get_project
File "compose/config/config.py", line 323, in load
File "compose/config/config.py", line 416, in load_services
File "compose/config/config.py", line 395, in build_services
File "compose/config/config.py", line 380, in build_service
File "compose/config/config.py", line 484, in run
File "compose/config/config.py", line 528, in resolve_extends
File "compose/config/config.py", line 774, in merge_service_dicts
File "compose/config/config.py", line 728, in merge_field
File "compose/config/config.py", line 807, in merge_logging
File "compose/config/config.py", line 750, in merge_scalar
AttributeError: 'NoneType' object has no attribute 'get'
docker-compose returned -1

# Fixed code
def merge_service_dicts(base, override, version):
    md = MergeDict(base, override)

    md.merge_mapping("environment", parse_environment)
    md.merge_mapping("labels", parse_labels)
    md.merge_mapping("ulimits", parse_ulimits)
    md.merge_mapping("networks", parse_networks)
    md.merge_sequence("links", ServiceLink.parse)

    for field in ["volumes", "devices"]:
        md.merge_field(field, merge_path_mappings)

    for field in [
        "ports",
        "cap_add",
        "cap_drop",
        "expose",
        "external_links",
        "security_opt",
        "volumes_from",
        "depends_on",
    ]:
        md.merge_field(field, merge_unique_items_lists, default=[])

    for field in ["dns", "dns_search", "env_file", "tmpfs"]:
        md.merge_field(field, merge_list_or_string)

    md.merge_field("logging", merge_logging, default={})

    for field in set(ALLOWED_KEYS) - set(md):
        md.merge_scalar(field)

    if version == V1:
        legacy_v1_merge_image_or_build(md, base, override)
    elif md.needs_merge("build"):
        md["build"] = merge_build(md, base, override)

    return dict(md)