[PR #7] [MERGED] Fix AttributeError when handling 302 redirects: initialize _ws_blacklist as set() #1

Closed
opened 2026-07-19 11:33:35 +03:00 by mirror-bot · 0 comments

📋 Pull Request Information

Original PR: https://github.com/Flowseal/tg-ws-proxy/pull/7
Author: @Copilot
Created: 3/4/2026
Status: ✅ Merged
Merged: 3/4/2026
Merged by: @Flowseal

Base: main ← Head: copilot/fix-attribute-error-dict-add


📝 Commits (2)

  • 5228dbb Initial plan
  • 0401a4c fix: initialize _ws_blacklist as set() instead of {}

📊 Changes

1 file changed (+1 additions, -1 deletions)

View changed files

📝 tg_ws_proxy.py (+1 -1)

📄 Description

_ws_blacklist was typed as Set[Tuple[int, bool]] but initialized with {} (a dict), causing AttributeError: 'dict' object has no attribute 'add' on every 302 redirect.

Change

# Before
_ws_blacklist: Set[Tuple[int, bool]] = {}

# After
_ws_blacklist: Set[Tuple[int, bool]] = set()
Original prompt

This section details on the original issue you should resolve

<issue_title>Ошибка AttributeError: 'dict' object has no attribute 'add' при обработке редиректов (302)</issue_title>
<issue_description>Переменная _ws_blacklist инициализируется как пустой словарь {}, но в коде она используется как множество set через вызов метода .add().
{} - это пустой словарь, поэтому при попытке добавить в него DC после редиректа возникает исключение:
AttributeError: 'dict' object has no attribute 'add'

2026-03-04 23:25:18  INFO   tg-ws-proxy  [127.0.0.1:58675] DC203 (91.105.192.100:443) -> wss://kws203-1.telegram.org/apiws via 149.154.167.220

2026-03-04 23:25:18  WARNING  tg-ws-proxy  [127.0.0.1:58675] DC203 got 302 from kws203-1.telegram.org -> https://core.telegram.org

2026-03-04 23:25:18  ERROR  tg-ws-proxy  [127.0.0.1:58675] unexpected: 'dict' object has no attribute 'add'

решение - поменять _ws_blacklist: Set[Tuple[int, bool]] = {} на _ws_blacklist: Set[Tuple[int, bool]] = set()</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Flowseal/tg-ws-proxy/pull/7 **Author:** [@Copilot](https://github.com/apps/copilot-swe-agent) **Created:** 3/4/2026 **Status:** ✅ Merged **Merged:** 3/4/2026 **Merged by:** [@Flowseal](https://github.com/Flowseal) **Base:** `main` ← **Head:** `copilot/fix-attribute-error-dict-add` --- ### 📝 Commits (2) - [`5228dbb`](https://github.com/Flowseal/tg-ws-proxy/commit/5228dbbdadab944dd0751713de32bc0ff9f2b6b1) Initial plan - [`0401a4c`](https://github.com/Flowseal/tg-ws-proxy/commit/0401a4c6bbf46d3363b3e19bb9ae407c166a69d3) fix: initialize _ws_blacklist as set() instead of {} ### 📊 Changes **1 file changed** (+1 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `tg_ws_proxy.py` (+1 -1) </details> ### 📄 Description `_ws_blacklist` was typed as `Set[Tuple[int, bool]]` but initialized with `{}` (a `dict`), causing `AttributeError: 'dict' object has no attribute 'add'` on every 302 redirect. ## Change ```python # Before _ws_blacklist: Set[Tuple[int, bool]] = {} # After _ws_blacklist: Set[Tuple[int, bool]] = set() ``` <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>Ошибка AttributeError: 'dict' object has no attribute 'add' при обработке редиректов (302)</issue_title> > <issue_description>Переменная _ws_blacklist инициализируется как пустой словарь {}, но в коде она используется как множество set через вызов метода .add(). > {} - это пустой словарь, поэтому при попытке добавить в него DC после редиректа возникает исключение: > AttributeError: 'dict' object has no attribute 'add' > > ``` > 2026-03-04 23:25:18 INFO tg-ws-proxy [127.0.0.1:58675] DC203 (91.105.192.100:443) -> wss://kws203-1.telegram.org/apiws via 149.154.167.220 > > 2026-03-04 23:25:18 WARNING tg-ws-proxy [127.0.0.1:58675] DC203 got 302 from kws203-1.telegram.org -> https://core.telegram.org > > 2026-03-04 23:25:18 ERROR tg-ws-proxy [127.0.0.1:58675] unexpected: 'dict' object has no attribute 'add' > ``` > > решение - поменять `_ws_blacklist: Set[Tuple[int, bool]] = {}` на `_ws_blacklist: Set[Tuple[int, bool]] = set()`</issue_description> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> <!-- START COPILOT CODING AGENT SUFFIX --> - Fixes Flowseal/tg-ws-proxy#6 <!-- START COPILOT CODING AGENT TIPS --> --- 💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
mirror-bot added the pull-request label 2026-07-19 11:33:35 +03:00
mirror-bot changed title from [PR #7] [MERGED] Fix AttributeError when handling 302 redirects: initialize _ws_blacklist as set() to [PR #7] Fix AttributeError when handling 302 redirects: initialize _ws_blacklist as set() 2026-07-20 04:08:05 +03:00
mirror-bot changed title from [PR #7] Fix AttributeError when handling 302 redirects: initialize _ws_blacklist as set() to [PR #7] [MERGED] Fix AttributeError when handling 302 redirects: initialize _ws_blacklist as set() 2026-07-20 22:54:20 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Utilities/tg-ws-proxy#1