# Buggy code
def denormalize_service_dict(service_dict, version):
    service_dict = service_dict.copy()

    if "restart" in service_dict:
        service_dict["restart"] = types.serialize_restart_spec(service_dict["restart"])

    if version == V1 and "network_mode" not in service_dict:
        service_dict["network_mode"] = "bridge"

    if "depends_on" in service_dict and version != V2_1:
        service_dict["depends_on"] = sorted(
            [svc for svc in service_dict["depends_on"].keys()]
        )

    if "healthcheck" in service_dict:
        if "interval" in service_dict["healthcheck"]:
            service_dict["healthcheck"]["interval"] = serialize_ns_time_value(
                service_dict["healthcheck"]["interval"]
            )
        if "timeout" in service_dict["healthcheck"]:
            service_dict["healthcheck"]["timeout"] = serialize_ns_time_value(
                service_dict["healthcheck"]["timeout"]
            )

    return service_dict


# Traceback (AttributeError)
$ docker-compose config
Traceback (most recent call last):
File "/usr/local/bin/docker-compose", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python2.7/site-packages/compose/cli/main.py", line 88, in main
command()
File "/usr/local/lib/python2.7/site-packages/compose/cli/main.py", line 134, in perform_command
handler(command, options, command_options)
File "/usr/local/lib/python2.7/site-packages/compose/cli/main.py", line 330, in config
compose_config = get_config_from_options(self.project_dir, config_options)
File "/usr/local/lib/python2.7/site-packages/compose/cli/command.py", line 46, in get_config_from_options
config.find(base_dir, config_path, environment)
File "/usr/local/lib/python2.7/site-packages/compose/config/config.py", line 333, in load
service_dicts = load_services(config_details, main_file)
File "/usr/local/lib/python2.7/site-packages/compose/config/config.py", line 455, in load_services
service_config = merge_services(service_config, next_config)
File "/usr/local/lib/python2.7/site-packages/compose/config/config.py", line 446, in merge_services
for name in all_service_names
File "/usr/local/lib/python2.7/site-packages/compose/config/config.py", line 446, in <dictcomp>
for name in all_service_names
File "/usr/local/lib/python2.7/site-packages/compose/config/config.py", line 797, in merge_service_dicts_from_files
new_service = merge_service_dicts(base, override, version)
File "/usr/local/lib/python2.7/site-packages/compose/config/config.py", line 856, in merge_service_dicts
md.merge_sequence('secrets', types.ServiceSecret.parse)
File "/usr/local/lib/python2.7/site-packages/compose/config/config.py", line 839, in merge_sequence
self[field] = [item.repr() for item in sorted(merged.values())]
AttributeError: 'ServiceSecret' object has no attribute 'repr'
$

# Fixed code
def denormalize_service_dict(service_dict, version):
    service_dict = service_dict.copy()

    if "restart" in service_dict:
        service_dict["restart"] = types.serialize_restart_spec(service_dict["restart"])

    if version == V1 and "network_mode" not in service_dict:
        service_dict["network_mode"] = "bridge"

    if "depends_on" in service_dict and version != V2_1:
        service_dict["depends_on"] = sorted(
            [svc for svc in service_dict["depends_on"].keys()]
        )

    if "healthcheck" in service_dict:
        if "interval" in service_dict["healthcheck"]:
            service_dict["healthcheck"]["interval"] = serialize_ns_time_value(
                service_dict["healthcheck"]["interval"]
            )
        if "timeout" in service_dict["healthcheck"]:
            service_dict["healthcheck"]["timeout"] = serialize_ns_time_value(
                service_dict["healthcheck"]["timeout"]
            )

    if "secrets" in service_dict:
        service_dict["secrets"] = map(lambda s: s.repr(), service_dict["secrets"])

    return service_dict