Skip to content

Commit a6bf747

Browse files
committed
fix slack capture
Signed-off-by: Sylvain Hellegouarch <sh@defuze.org>
1 parent 8ec726b commit a6bf747

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

CHANGELOG.md

+9-6
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,19 @@
22

33
## [Unreleased][]
44

5-
[Unreleased]: https://github.com/chaostoolkit-incubator/chaostoolkit-reliably/compare/0.65.0...HEAD
5+
[Unreleased]: https://github.com/chaostoolkit-incubator/chaostoolkit-reliably/compare/0.65.1...HEAD
66

7-
## [0.65.0][]
7+
## [0.65.1][]
88

9-
[0.65.0]: https://github.com/chaostoolkit-incubator/chaostoolkit-reliably/compare/0.64.0...0.65.0
9+
[0.65.1]: https://github.com/chaostoolkit-incubator/chaostoolkit-reliably/compare/0.64.0...0.65.1
1010

11-
### Changed
11+
## [0.65.1][]
1212

13-
* Remove Reliably bot thread from the history to prevent polutting the timeline
14-
* Bump dependencies
13+
[0.65.1]: https://github.com/chaostoolkit-incubator/chaostoolkit-reliably/compare/0.65.0...0.65.1
14+
15+
### Fixed
16+
17+
* Fix thread removal in slack capture
1518

1619
## [0.64.0][]
1720

chaosreliably/controls/capture/slack.py

+5-10
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ def stop_capturing(
4343
channel, limit, past, include_metadata, secrets
4444
)
4545

46-
if history:
47-
remove_bot_threads(history)
48-
4946
return history
5047

5148

@@ -153,6 +150,8 @@ def get_channel_history(
153150
if user_id not in users:
154151
users[user_id] = get_user_info(client, user_id)
155152

153+
remove_bot_threads(threads)
154+
156155
context = {
157156
"channels": [
158157
{
@@ -221,12 +220,8 @@ def get_thread_history(
221220
return messages
222221

223222

224-
def remove_bot_threads(history: Dict[str, Any]) -> None:
225-
threads = history.get("threads")
226-
if not threads:
227-
return None
228-
229-
for t in threads:
223+
def remove_bot_threads(threads: Dict[str, Any]) -> None:
224+
for ts, t in threads.items():
230225
# flaky heuristic
231226
bot_id = t.get("bot_id")
232227
t_type = t.get("type")
@@ -236,7 +231,7 @@ def remove_bot_threads(history: Dict[str, Any]) -> None:
236231
and t_type == "message"
237232
and t_text.startswith("Experiment is ")
238233
):
239-
threads.remove(t)
234+
threads.pop(ts, None)
240235
break
241236

242237
return None

0 commit comments

Comments
 (0)