Skip to content

Commit 5c7df65

Browse files
authored
Bug Fix - chatgpt_plugin.py
Fixing error where the cache file size is zero and checking if user information timestamp is None.
1 parent 5a5e749 commit 5c7df65

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

Diff for: plugins/chatgpt_plugin.py

+15-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ def get_chatgpt_chatinfo(profile: BrowserProfileProtocol, log_func: LogFunction,
1515
results = []
1616

1717
for cache_rec in profile.iterate_cache(url=CONVERSATION_API_URL_PATTERN):
18+
if cache_rec.data is None:
19+
log_func(f"Error: ChatGPT chat information cache file is size is zero! Skipping file.")
20+
continue
21+
1822
cache_data = json.loads(cache_rec.data.decode("utf-8"))
1923

2024
items = cache_data.get("items", {})
@@ -58,13 +62,21 @@ def get_chatgpt_userinfo(profile: BrowserProfileProtocol, log_func: LogFunction,
5862
results = []
5963

6064
for cache_rec in profile.iterate_cache(url=USER_DETAILS_API_URL_PATTERN):
65+
if cache_rec.data is None:
66+
log_func(f"Error: ChatGPT user information cache file is size is zero! Skipping file.")
67+
continue
68+
6169
cache_data = json.loads(cache_rec.data.decode("utf-8"))
6270

6371
name = cache_data.get("name")
6472
email = cache_data.get("email")
6573
phone_number = cache_data.get("phone_number")
6674
created = cache_data.get("created")
67-
standard_timestamp = datetime.fromtimestamp(created)
75+
76+
if created is None:
77+
standard_timestamp = None
78+
else:
79+
standard_timestamp = datetime.fromtimestamp(created)
6880

6981
result = {
7082
"Created": str(standard_timestamp),
@@ -85,15 +97,15 @@ def get_chatgpt_userinfo(profile: BrowserProfileProtocol, log_func: LogFunction,
8597
"ChatGPT",
8698
"ChatGPT Chat Information",
8799
"Recovers ChatGPT chat information from History and Cache",
88-
"0.1",
100+
"0.2",
89101
get_chatgpt_chatinfo,
90102
ReportPresentation.table
91103
),
92104
ArtifactSpec(
93105
"ChatGPT",
94106
"ChatGPT User Information",
95107
"Recovers ChatGPT user information from Cache",
96-
"0.1",
108+
"0.2",
97109
get_chatgpt_userinfo,
98110
ReportPresentation.table
99111
),

0 commit comments

Comments
 (0)