test(telegram): pin comma-string allow_from / group_allow_from in adapter auth - #63350
test(telegram): pin comma-string allow_from / group_allow_from in adapter auth#63350Rival wants to merge 1 commit into
Conversation
|
Rebased onto current When this branch was cut, the adapter-level branch built its allow-set inline: allowed = {str(u).strip() for u in adapter_allow_from if str(u).strip()}Iterating a comma-string char-wise there is the lockout bug. Two other things the rebase surfaced:
Verified adversarially: reverting Happy to close this instead if you would rather not carry the extra coverage. |
SummaryThirteen PRs address or reference three connected Telegram authorization problems: the original missing user/group controls, intake short-circuits that mask YAML or environment grants, and scalar parsing plus preservation of the documented global/group/chat authorization union. The diffs include the merged gateway implementation in #17748, overlapping group/DM fixes in #55496 and #55529, focused scalar regressions in #63350 and #64473, and broader union work culminating in #72084. Related pull requests
Duplicates#7659 and #17686 are predecessors of merged #17748; #55624 and #57189 duplicate the group-side work contained in #55496/#55529, with #55529 adding the complementary DM path. #63350 overlaps #64473 on CSV scalar coverage, while #68784 and #69617 are superseded approaches to the union problem carried forward more comprehensively by #72084. Suggested consolidationKeep #55529 open with a salvage path: preserve its combined group/DM fix, repair the explicit-empty fail-closed case identified on #55496, and add the alias and precedence documentation required by its maintainer-bot review. Close #55496 as duplicate of #55529 despite the keep_open review on #55496, because #55529's visible diff contains the same group/forum ordering and alias changes plus the missing DM fallback, while retaining the review's empty-list requirement for the consolidated patch; keep #63350 open for its focused regression tests, require author action on #64473 to preserve tuple/set iterable normalization, and require author action on recorded best fix #72084 to rebase onto main or split out the current intake/runner union and multiplex profile-scope work. Complex graphflowchart LR
classDef open fill:#dbeafe,stroke:#1d4ed8,color:#1e3a8a
classDef merged fill:#dcfce7,stroke:#15803d,color:#14532d
classDef closed fill:#e5e7eb,stroke:#6b7280,color:#1f2937
classDef unverified fill:#f3f4f6,stroke:#9ca3af,color:#374151
classDef best stroke-width:3px,stroke:#b45309
classDef target stroke-width:3px,stroke:#4338ca
subgraph Dup63350 ["PRs duplicating each other"]
P63350["PR #63350 (open)"]
P64473["PR #64473 (open)"]
end
class P63350 open
class P64473 open
class P63350 target
click P63350 "https://github.com/NousResearch/hermes-agent/pull/63350"
click P64473 "https://github.com/NousResearch/hermes-agent/pull/64473"
Graph: solid arrow = fixes / best fix, dashed arrow = partial or unverified (see edge label); boxed group = PRs duplicating each other; amber border = best fix; indigo border = target; gray node = closed (state tag in the node label). Cross-PR triage: Reviewed 13 pull requests and 3 issues in this complex. Each diff was read against this issue; Assessment working set: 189 kB of PR diffs, 30 kB of issue/PR text, 25 kB of discussion (42 comments), 16 verify verdicts. verdicts reflect diff content, not PR titles. Part of an automated triage batch. |
…pter auth
``_coerce_allow_set`` splits a scalar string on commas so
``allow_from: "111,222"`` yields {"111", "222"} rather than a set of single
characters. Nothing pinned that through the Telegram adapter's DM and group
branches — the existing coverage passes list forms only, so a regression to
char-wise iteration would lock every real id out (and admit stray one-char
matches) without failing a test.
Four cases: comma-string allow_from on the DM branch, comma-string
group_allow_from on the group branch (the two keys are selected by chat type
but parsed identically), surrounding whitespace, and a bare "*" scalar
wildcard.
Tests only — no production change.
|
Rebased onto The textual conflict would have re-added those. Rather than resolve it hunk by hunk, I rebuilt the commit on top of the current file so it adds only the four comma-string cases, immediately after the surviving list-form test:
Diff is now +56/-0 — purely additive, no lines of yours touched. Negative-checked: making Still tests-only, as described in the earlier comment — the production fix this PR originally carried became a no-op once |
What
Three tests in
tests/gateway/test_telegram_auth_check.pypinning that a comma-stringallow_from/group_allow_frombehaves exactly like the equivalent YAML list inTelegramAdapter._is_user_authorized_from_message.No production change.
Why
_is_user_authorized_from_messagepicksgroup_allow_fromforgroup/forum/channelandallow_fromfor DMs, then parses whichever it chose with_coerce_allow_set. Both keys accept either form:allow_fromis",".join(...)-ed ontoTELEGRAM_ALLOWED_USERS, and the env branch of this same method splits it;allow_from: "111,222"— reaches the adapter as one string.If such a value were ever iterated directly instead of split, the allow-set would become single characters: every real user id rejected, locking the owner out of their own bot. That is a lockout-class failure, and it is the failure this branch originally shipped a fix for.
_coerce_allow_sethandles it correctly today. But the existing adapter-auth tests (..._allow_from,..._group_allow_from) exercise the list form only — nothing pins the string form through either branch, so the behavior could regress silently.Ships
..._comma_string_allow_from— comma-string viaallow_fromon a DM...._comma_string_group_allow_from— comma-string viagroup_allow_fromin a group...._comma_string_with_spaces—" 111 , 222 "tolerated (same.strip()as the env branch)...._comma_string_wildcard— a bare*scalar still wildcards.Verified adversarially: reverting
_coerce_allow_setto the pre-extraction{str(u).strip() for u in raw}comprehension makes three of these four fail. (The wildcard case passes either way — iterating"*"char-wise still yields{"*"}— so it is coverage, not a discriminator.)