t-bug-catcher 0.4.2__tar.gz → 0.4.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. {t_bug_catcher-0.4.2 → t_bug_catcher-0.4.4}/PKG-INFO +1 -1
  2. {t_bug_catcher-0.4.2 → t_bug_catcher-0.4.4}/setup.cfg +1 -1
  3. {t_bug_catcher-0.4.2 → t_bug_catcher-0.4.4}/setup.py +1 -1
  4. {t_bug_catcher-0.4.2 → t_bug_catcher-0.4.4}/t_bug_catcher/__init__.py +1 -1
  5. {t_bug_catcher-0.4.2 → t_bug_catcher-0.4.4}/t_bug_catcher/bug_catcher.py +8 -0
  6. {t_bug_catcher-0.4.2 → t_bug_catcher-0.4.4}/t_bug_catcher/config.py +9 -0
  7. {t_bug_catcher-0.4.2 → t_bug_catcher-0.4.4}/t_bug_catcher/jira.py +14 -0
  8. {t_bug_catcher-0.4.2 → t_bug_catcher-0.4.4}/t_bug_catcher/stack_saver.py +10 -0
  9. {t_bug_catcher-0.4.2 → t_bug_catcher-0.4.4}/t_bug_catcher.egg-info/PKG-INFO +1 -1
  10. {t_bug_catcher-0.4.2 → t_bug_catcher-0.4.4}/MANIFEST.in +0 -0
  11. {t_bug_catcher-0.4.2 → t_bug_catcher-0.4.4}/README.rst +0 -0
  12. {t_bug_catcher-0.4.2 → t_bug_catcher-0.4.4}/pyproject.toml +0 -0
  13. {t_bug_catcher-0.4.2 → t_bug_catcher-0.4.4}/requirements.txt +0 -0
  14. {t_bug_catcher-0.4.2 → t_bug_catcher-0.4.4}/t_bug_catcher/bug_snag.py +0 -0
  15. {t_bug_catcher-0.4.2 → t_bug_catcher-0.4.4}/t_bug_catcher/exceptions.py +0 -0
  16. {t_bug_catcher-0.4.2 → t_bug_catcher-0.4.4}/t_bug_catcher/resources/whispers_config.yml +0 -0
  17. {t_bug_catcher-0.4.2 → t_bug_catcher-0.4.4}/t_bug_catcher/utils/__init__.py +0 -0
  18. {t_bug_catcher-0.4.2 → t_bug_catcher-0.4.4}/t_bug_catcher/utils/common.py +0 -0
  19. {t_bug_catcher-0.4.2 → t_bug_catcher-0.4.4}/t_bug_catcher/utils/logger.py +0 -0
  20. {t_bug_catcher-0.4.2 → t_bug_catcher-0.4.4}/t_bug_catcher/workitems.py +0 -0
  21. {t_bug_catcher-0.4.2 → t_bug_catcher-0.4.4}/t_bug_catcher.egg-info/SOURCES.txt +0 -0
  22. {t_bug_catcher-0.4.2 → t_bug_catcher-0.4.4}/t_bug_catcher.egg-info/dependency_links.txt +0 -0
  23. {t_bug_catcher-0.4.2 → t_bug_catcher-0.4.4}/t_bug_catcher.egg-info/not-zip-safe +0 -0
  24. {t_bug_catcher-0.4.2 → t_bug_catcher-0.4.4}/t_bug_catcher.egg-info/requires.txt +0 -0
  25. {t_bug_catcher-0.4.2 → t_bug_catcher-0.4.4}/t_bug_catcher.egg-info/top_level.txt +0 -0
  26. {t_bug_catcher-0.4.2 → t_bug_catcher-0.4.4}/tests/test_t_bug_catcher.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: t_bug_catcher
3
- Version: 0.4.2
3
+ Version: 0.4.4
4
4
  Summary: Bug catcher
5
5
  Home-page: https://www.thoughtful.ai/
6
6
  Author: Thoughtful
@@ -1,5 +1,5 @@
1
1
  [bumpversion]
2
- current_version = 0.4.2
2
+ current_version = 0.4.4
3
3
  commit = True
4
4
  tag = False
5
5
 
@@ -26,7 +26,7 @@ setup(
26
26
  packages=find_packages(include=["t_bug_catcher", "t_bug_catcher.*"]),
27
27
  test_suite="tests",
28
28
  url="https://www.thoughtful.ai/",
29
- version="0.4.2",
29
+ version="0.4.4",
30
30
  zip_safe=False,
31
31
  install_requires=install_requirements,
32
32
  include_package_data=True,
@@ -3,7 +3,7 @@
3
3
  __author__ = """Thoughtful"""
4
4
  __email__ = "support@thoughtful.ai"
5
5
  # fmt: off
6
- __version__ = '0.4.2'
6
+ __version__ = '0.4.4'
7
7
  # fmt: on
8
8
 
9
9
  from .bug_catcher import (
@@ -128,6 +128,14 @@ class BugCatcher:
128
128
  if not exception:
129
129
  _, exception, _ = sys.exc_info()
130
130
 
131
+ if not isinstance(exception, Exception):
132
+ logger.warning("Exception must be an instance of Exception.")
133
+ return
134
+
135
+ if not getattr(exception, "__traceback__", None):
136
+ logger.warning("No traceback available. Please provide a traceback.")
137
+ return
138
+
131
139
  handled_error = getattr(exception, "handled_error", None)
132
140
  if handled_error:
133
141
  logger.warning(f"Exception {handled_error} already reported.")
@@ -15,6 +15,15 @@ class Config:
15
15
  SUMMARY_LENGTH: int = 120
16
16
  STACK_SCOPE: int = 3
17
17
 
18
+ class TICKET_PRIORITIES:
19
+ """Priorities class for configuring the application."""
20
+
21
+ HIGHEST: str = "1"
22
+ HIGH: str = "2"
23
+ MEDIUM: str = "3"
24
+ LOW: str = "4"
25
+ LOWEST: str = "5"
26
+
18
27
  SUPPORT_BOARD = "AB"
19
28
 
20
29
  KEYS_TO_REMOVE = ["credential", "password"]
@@ -209,6 +209,7 @@ class Jira:
209
209
  issue_type: str,
210
210
  assignee: Optional[str] = None,
211
211
  labels: Optional[list] = None,
212
+ priority: Optional[str] = None,
212
213
  ) -> str:
213
214
  """Generates the issue body payload for creating a new issue.
214
215
 
@@ -218,6 +219,7 @@ class Jira:
218
219
  assignee (str): The assignee of the issue.
219
220
  issue_type (str): The type of the issue.
220
221
  labels (list, optional): The labels of the issue. Defaults to None.
222
+ priority (str, optional): The priority of the issue. Defaults to None.
221
223
 
222
224
  Returns:
223
225
  The JSON payload for creating a new issue.
@@ -235,6 +237,8 @@ class Jira:
235
237
  fields["fields"]["labels"] = labels
236
238
  if self._project_key == CONFIG.SUPPORT_BOARD and CONFIG.ADMIN_CODE:
237
239
  fields["fields"]["customfield_10077"] = [CONFIG.ADMIN_CODE]
240
+ if priority:
241
+ fields["fields"]["priority"] = {"id": priority}
238
242
  payload = json.dumps(fields)
239
243
  return payload
240
244
 
@@ -890,6 +894,7 @@ class Jira:
890
894
  assignee_id: Optional[str] = None,
891
895
  attachments: Optional[List] = None,
892
896
  labels: Optional[list] = None,
897
+ priority: Optional[str] = None,
893
898
  ) -> requests.Response:
894
899
  """Create a new ticket.
895
900
 
@@ -899,6 +904,7 @@ class Jira:
899
904
  assignee_id (str, optional): The assignee of the ticket. Defaults to None.
900
905
  attachments (List, optional): The list of attachments. Defaults to None.
901
906
  labels (List, optional): The list of labels. Defaults to None.
907
+ priority (str, optional): The priority of the ticket. Defaults to None.
902
908
 
903
909
  Returns:
904
910
  The response from creating the ticket.
@@ -923,6 +929,7 @@ class Jira:
923
929
  assignee=assignee_id,
924
930
  issue_type=issue_type,
925
931
  labels=labels,
932
+ priority=priority,
926
933
  )
927
934
  response = self.post_ticket(issue=issue)
928
935
 
@@ -932,6 +939,7 @@ class Jira:
932
939
  description=description,
933
940
  assignee=assignee_id,
934
941
  issue_type=issue_type,
942
+ priority=priority,
935
943
  )
936
944
  response = self.post_ticket(issue=issue)
937
945
 
@@ -1034,12 +1042,15 @@ class Jira:
1034
1042
  metadata=metadata,
1035
1043
  )
1036
1044
 
1045
+ priority = CONFIG.TICKET_PRIORITIES.HIGH if CONFIG.STAGE.lower() == "hypercare" else None
1046
+
1037
1047
  response = self.__create_new_ticket(
1038
1048
  summary=summary,
1039
1049
  description=description,
1040
1050
  assignee_id=assignee_id,
1041
1051
  attachments=attachments,
1042
1052
  labels=["bug_catcher"],
1053
+ priority=priority,
1043
1054
  )
1044
1055
  if os.path.exists(stack_trace):
1045
1056
  os.remove(stack_trace)
@@ -1091,12 +1102,15 @@ class Jira:
1091
1102
  error_id=error_id,
1092
1103
  )
1093
1104
 
1105
+ priority = CONFIG.TICKET_PRIORITIES.HIGHEST if CONFIG.STAGE.lower() == "hypercare" else None
1106
+
1094
1107
  response = self.__create_new_ticket(
1095
1108
  summary=summary,
1096
1109
  description=description,
1097
1110
  assignee_id=assignee_id,
1098
1111
  attachments=[stack_trace] if stack_trace else None,
1099
1112
  labels=["bug_catcher", "fatal_error"],
1113
+ priority=priority,
1100
1114
  )
1101
1115
  if os.path.exists(stack_trace):
1102
1116
  os.remove(stack_trace)
@@ -1,5 +1,6 @@
1
1
  import inspect
2
2
  import json
3
+ import linecache
3
4
  import os
4
5
  import re
5
6
  import sys
@@ -48,6 +49,8 @@ class StackSaver:
48
49
  serializable_frame_info = {
49
50
  "filename": frame_info["filename"],
50
51
  "function_name": frame_info["function_name"],
52
+ "line_number": frame_info["line_number"],
53
+ "line": frame_info["line"],
51
54
  "locals": run_locals,
52
55
  "args": run_args,
53
56
  }
@@ -126,9 +129,14 @@ class StackSaver:
126
129
  try:
127
130
  frames = []
128
131
  stack_details_json = []
132
+ seen_frames = set()
129
133
  tb = exception.__traceback__ if exception else sys.exc_info()[2]
130
134
  while tb is not None:
131
135
  frame = tb.tb_frame
136
+ if frame.f_code.co_name in seen_frames:
137
+ tb = tb.tb_next
138
+ continue
139
+ seen_frames.add(frame.f_code.co_name)
132
140
  if "site-packages" in frame.f_code.co_filename:
133
141
  tb = tb.tb_next
134
142
  continue
@@ -140,6 +148,8 @@ class StackSaver:
140
148
  frame_info = {
141
149
  "filename": self.strip_path(frame.f_code.co_filename),
142
150
  "function_name": frame.f_code.co_name,
151
+ "line_number": frame.f_lineno,
152
+ "line": linecache.getline(frame.f_code.co_filename, frame.f_lineno).strip(),
143
153
  "locals": self.filter_variables(frame.f_locals),
144
154
  "args": self.filter_variables(inspect.getargvalues(frame)[3]),
145
155
  }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: t_bug_catcher
3
- Version: 0.4.2
3
+ Version: 0.4.4
4
4
  Summary: Bug catcher
5
5
  Home-page: https://www.thoughtful.ai/
6
6
  Author: Thoughtful
File without changes
File without changes