Skip to content

Commit 48f7d59

Browse files
authored
Fix-project-export (#2062)
* Fix project export error when no project QP * Add traceback
1 parent 7cc099f commit 48f7d59

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

sonar/projects.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import json
3131
import concurrent.futures
3232
from datetime import datetime
33+
import traceback
3334

3435
from typing import Optional, Union
3536
from http import HTTPStatus
@@ -1042,6 +1043,7 @@ def export(self, export_settings: types.ConfigSettings, settings_list: Optional[
10421043
json_data["settings"] = [s.to_json() for s in settings_dict.values() if with_inherited or not s.inherited and s.key != "visibility"]
10431044

10441045
except Exception as e:
1046+
traceback.print_exc()
10451047
util.handle_error(e, f"exporting {str(self)}, export of this project interrupted", catch_all=True)
10461048
json_data["error"] = f"{util.error_msg(e)} while exporting project"
10471049
log.debug("Exporting %s done, returning %s", str(self), util.json_dump(json_data))

sonar/utilities.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,8 @@ def dict_remap_and_stringify(original_dict: dict[str, str], remapping: dict[str,
732732

733733
def list_to_dict(original_list: list[dict[str, Any]], key_field: str) -> dict[str, any]:
734734
"""Converts a list to dict with list key_field as dict key"""
735+
if original_list is None:
736+
return original_list
735737
converted_dict = {elem[key_field]: elem for elem in original_list}
736738
for e in converted_dict.values():
737739
e.pop(key_field)
@@ -740,7 +742,7 @@ def list_to_dict(original_list: list[dict[str, Any]], key_field: str) -> dict[st
740742

741743
def dict_to_list(original_dict: dict[str, Any], key_field: str, value_field: Optional[str] = "value") -> list[str, any]:
742744
"""Converts a dict to list adding dict key in list key_field"""
743-
if isinstance(original_dict, list):
745+
if original_dict is None or isinstance(original_dict, list):
744746
return original_dict
745747
return [{key_field: key, value_field: elem} if not isinstance(elem, dict) else {key_field: key, **elem} for key, elem in original_dict.items()]
746748

0 commit comments

Comments
 (0)