Skip to content

fix(irc): fallback nick exceeds 30 characters after repeat nick collisions - #196619

Merged
obviyus merged 4 commits into
openclaw:mainfrom
Mahdi-Hasan:fix/irc-fallback-nick-length
Nov 10, 2026
Merged

obviyus merged 4 commits into
openclaw:mainfrom
Mahdi-Hasan:fix/irc-fallback-nick-length

Conversation

@Mahdi-Hasan

@Mahdi-Hasan Mahdi-Hasan commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: the IRC bot can send a fallback nick longer than 30 characters when its configured nick is 28–29 characters long and the nick is taken more than once in the same process.

User Impact

User impact: an IRC bot with a long nick now recovers from repeated nick collisions with a nick that stays within the 30-character cap, instead of sending an over-long NICK that the server truncates (and may collide again) or rejects with 432, which fails the connection.

Why This Change Was Made

buildFallbackNick only truncated when the base nick alone was already at the cap. The suffix grows with the collision counter (_, _2, _10, …), so a 29-character base plus _2 produced 31 characters. The check now compares base plus suffix against the cap, so truncation kicks in whenever the suffix would push the nick past 30.

Evidence

Real Gateway proof against a real IRC server

Setup, same for both runs:

  • Ergo IRC server in Docker on loopback, default config with limits.nicklen: 30.
  • A separate client holds the nick openclawproofnickabcdefghijkl (29 characters) and WHOISes the fallback nicks every 5 s.
  • Isolated Gateway (OPENCLAW_HOME, OPENCLAW_STATE_DIR, OPENCLAW_CONFIG_PATH in a temp dir), plaintext loopback, two IRC accounts first and second both configured with that nick. Both connect at startup in one process, so the second collision gets the _2 suffix.

Before: published [email protected] with @openclaw/[email protected] (openclaw plugins install), openclaw gateway run:

[irc] [first] starting IRC provider (127.0.0.1:16667)
[irc] [second] starting IRC provider (127.0.0.1:16667)
[irc] [first] channel exited: IRC login failed (432): Erroneous nickname
[irc] [first] auto-restart attempt 1/10 in 5s
[irc] [first] channel exited: IRC login failed (432): Erroneous nickname
[irc] [first] auto-restart attempt 2/10 in 10s
[irc] [first] channel exited: IRC login failed (432): Erroneous nickname
[irc] [first] auto-restart attempt 3/10 in 21s
[irc] [first] channel exited: IRC login failed (432): Erroneous nickname
[irc] [first] auto-restart attempt 4/10 in 40s

Holder WHOIS: openclawproofnickabcdefghijkl_ exists (second); openclawproofnickabcdefghijkl_2 does not. Each auto-restart takes a new counter value (_3, _4, …), which is still 31 characters, so first never connects.

After: this branch from source (pnpm build, then pnpm openclaw gateway run):

[irc] [first] starting IRC provider (127.0.0.1:16667)
[irc] [second] starting IRC provider (127.0.0.1:16667)

No 432 and no auto-restart in the Gateway log. Holder WHOIS from the server:

:ergo.test 311 openclawproofnickabcdefghijkl openclawproofnickabcdefghijk_2 ~u cdvi2duzrc4jw.irc * OpenClaw
:ergo.test 311 openclawproofnickabcdefghijkl openclawproofnickabcdefghijkl_ ~u cdvi2duzrc4jw.irc * OpenClaw
:ergo.test 401 openclawproofnickabcdefghijkl openclawproofnickabcdefghijkl_2 :No such nick

Both accounts are registered; the second uses the 30-character openclawproofnickabcdefghijk_2.

Unit test

Added a 29-character case to the existing "normalizes and bounds fallback" test in extensions/irc/src/client.test.ts.

  • Without the fix: pnpm test extensions/irc/src/client.test.ts --maxWorkers=1 fails the new case with expected 31 to be less than or equal to 30.
  • With the fix: 43/43 tests in the file pass.
  • pnpm format:check and oxlint on both touched files: clean.

…sions

buildFallbackNick only truncated when the base nick was already at the
30-character cap. A 29-character nick on its second collision became
31 characters (base + "_2"), which servers truncate or reject with 432.
@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 10, 2026
@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

The PR includes the collision suffix when enforcing the existing 30-character fallback nickname limit.

Example: A second collision requires suffix _2 for configured nick openclawproofnickabcdefghijkl.

  • Before: The client sends openclawproofnickabcdefghijkl_2, exceeding 30 characters and receiving error 432.
  • After: The client sends openclawproofnickabcdefghijk_2, which stays within 30 characters.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A minimal invariant repair with relevant Gateway and server proof, reported red/green regression coverage, and no open findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (logs): The contributor exercises the changed IRC client through an isolated Gateway against real Ergo: two accounts collide on the same 29-character nickname, published 2026.11.2 repeatedly receives 432, and the branch registers both accounts with server WHOIS confirming the shortened _2 nickname; the production correction is unchanged from the previously proven head.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: IRC accounts using long nicknames can repeatedly fail to connect when collision recovery generates an overlong nickname.
Reason: The patch restores the existing length invariant within the established recovery owner and adds no product or configuration surface.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current IRC registration bug with the smallest complete change; no actionable findings remain, and current-head CI is still running.

Priority: P2
Reviewed head: c8c267c02fd18b19524bb747dc68b4a2da8a49a9

Before merge

None.

Findings

None.

Agent review details

How this fits together

The IRC plugin's shared TCP/TLS client handles registration collisions for Gateway accounts, outbound connections, and probes, producing fallback NICK commands for the server.

flowchart LR
  A[Gateway account] --> D[IRC client]
  B[Outbound connection] --> D
  C[Connection probe] --> D
  D --> E[Fallback nickname builder]
  E --> F[Bounded NICK command]
  F --> G[IRC server]
Loading

Technical review

Best possible solution:

Merge the focused length-check correction and its existing socket-level regression case once required checks pass.

Do we have a high-confidence way to reproduce the issue?

Main deterministically produces 31 characters from a 29-character base plus _2; the contributor also supplies published-release Gateway failure logs, while this read-only review executed no target code.

Is this the best way to solve the issue?

This is the smallest complete fix: the existing nickname builder enforces the complete output length without changing sanitization, counter ownership, callers, configuration, or persisted state.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against d290127ec675.

Provenance checked

  • Fallback nickname length cap keeps the original intent (fa906b2: First-class IRC support established nickname sanitization and the 30-character fallback cap.)
  • Incrementing collision suffix keeps the original intent (fix(irc): prevent ghost nick collisions on rejoin after network delay #96108: Repeated reconnects required distinct fallback nicknames to avoid collisions with ghost sessions.)
  • Fallback regression table keeps the original intent (12b56e6: Test consolidation retained owner-boundary scenarios while removing redundant layers; the replacement row catches the actual suffix-overflow failure using the same assertions.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Current-main defect and focused repair: Main compares only base.length with 30, allowing a 29-character base plus _2 to reach 31 characters; the introduced diff measures base plus suffix instead. (extensions/irc/src/client.ts:98, c8c267c02fd1)
  • Regression coverage: The existing socket-level collision table now uses a 29-character input, exercising the previously missed suffix overflow while retaining normalization and sequential-uniqueness coverage. (extensions/irc/src/client.test.ts:186, c8c267c02fd1)
  • Shipped-entry-point proof: The full PR body records isolated Gateway runs against real Ergo with nicklen 30: published 2026.11.2 repeatedly receives 432, while the branch registers both accounts; server WHOIS confirms the shortened _2 nickname. (c8c267c02fd1)
  • Collision-counter provenance: Merged fix(irc): prevent ghost nick collisions on rejoin after network delay #96108 introduced incrementing suffixes to avoid ghost-session collisions; this PR preserves that behavior and repairs its interaction with the existing length cap. (extensions/irc/src/client.ts:95, 6ce88ca51d05)
  • Discussion and current-head checks: Contributor proof resolves the earlier proof blocker, and collaborator obviyus requested re-review after updating the branch; GitHub reports a mergeable head with checks still in progress and no failed checks in the retrieved results. (c8c267c02fd1)

Likely related people:

  • wendy: Raw commit 6ce88ca adds extensions/irc/src/client.ts:75 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 6ce88ca51d05; files: extensions/irc/src/client.ts)
  • Peter Steinberger: Raw commit 12b56e6 adds extensions/irc/src/client.test.ts:184 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 12b56e6492c0; files: extensions/irc/src/client.test.ts)
  • Vignesh: Raw commit fa906b2 adds extensions/irc/src/client.ts:89 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: fa906b26add7; files: extensions/irc/src/client.ts)

PR surface

Source 0, Tests 0. Total 0 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 1 1 0
Tests 1 1 1 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 2 2 0

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Repeated collisions can prevent IRC accounts with long nicknames from registering; the affected configuration and repair are narrow.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (2 earlier review cycles)
  • reviewed 2026-11-10T11:12:10.228Z sha 9da055e :: needs real behavior proof before merge. :: none
  • reviewed 2026-11-10T13:09:28.243Z sha 9da055e :: needs maintainer review before merge. :: none

Reviewed November 10, 2026, 9:27 AM ET / 14:27 UTC (Revision 3).

@Mahdi-Hasan

Copy link
Copy Markdown
Contributor Author

Added real Gateway proof against a real IRC server (Ergo, nicklen 30) to the PR body. Published 2026.11.2 loops on 432 Erroneous nickname for the second account; this branch registers both, the second as the 30-character ..._2 nick.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 10, 2026
@obviyus

obviyus commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 10, 2026
@obviyus

obviyus commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator

Proof on a built Gateway (node:24.22.1, secretless Docker) against a real Ergo server with NICKLEN=30. Main and this branch were built from the same tree; main has only the one production line reverted. Messages were sent through the Gateway send RPC.

Bug case: configured nick proofbotnicklimit29charsabcde (29 chars). Other clients already hold that nick and the first fallback ..._.

  • Main: the first attempt gets 433 because ..._ is taken. Every restart after that gets IRC login failed (432): Erroneous nickname, because the _2, _3, ... fallbacks are 31 chars. The send also fails with 432.
  • This PR: the bot joins #proof as proofbotnicklimit29charsabcd_2 (30 chars). The send connects as ..._3 (30 chars) and the watcher receives PRIVMSG #proof :proof cand collide.

Controls (same result on main and on this PR):

  • Short nick shortbot while shortbot is taken: the bot joins as shortbot_, and the message arrives from shortbot_2.
  • Configured nick of 40 chars: the server returns 432 on every attempt, and the send fails with 432.
  • 29-char nick with no collision: the bot joins with the exact nick, and the message arrives from ..._ (30 chars).

I also merged current main, and replaced the over-limit test row with the 29-char row, so the net test-line change is 0.

@obviyus
obviyus merged commit 9203388 into openclaw:main Nov 10, 2026
96 checks passed
@obviyus

obviyus commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator

Landed in 9203388. Thanks @Mahdi-Hasan. Long IRC nicks now fall back within the server limit.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 11, 2026
…sions (openclaw#196619)

fix(irc): keep fallback nicks within the server's nick length

The IRC fallback nick was only shortened when the configured nick alone reached 30 characters. A 28- or 29-character nick plus a fallback suffix such as _2 or _10 went over the limit, so the server rejected it with 432 and the connection failed. The fallback is now trimmed so the nick plus its suffix stays within 30 characters.

Evidence: a built Gateway on node:24.22.1 in secretless Docker talking to a real Ergo IRC server with NICKLEN=30. With a 29-character nick and its first fallback already taken, main got "IRC login failed (432): Erroneous nickname" on every restart and sends failed with 432, because the _2 and _3 fallbacks were 31 characters. With this change the bot joined as a 30-character nick and its message reached a watching client. A short taken nick, a 40-character configured nick and a 29-character nick without a collision behave the same on both. Details: openclaw#196619 (comment).

Thanks @Mahdi-Hasan.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to clawhaven/openclaw that referenced this pull request Nov 23, 2026
…sions (openclaw#196619)

fix(irc): keep fallback nicks within the server's nick length

The IRC fallback nick was only shortened when the configured nick alone reached 30 characters. A 28- or 29-character nick plus a fallback suffix such as _2 or _10 went over the limit, so the server rejected it with 432 and the connection failed. The fallback is now trimmed so the nick plus its suffix stays within 30 characters.

Evidence: a built Gateway on node:24.22.1 in secretless Docker talking to a real Ergo IRC server with NICKLEN=30. With a 29-character nick and its first fallback already taken, main got "IRC login failed (432): Erroneous nickname" on every restart and sends failed with 432, because the _2 and _3 fallbacks were 31 characters. With this change the bot joined as a 30-character nick and its message reached a watching client. A short taken nick, a 40-character configured nick and a 29-character nick without a collision behave the same on both. Details: openclaw#196619 (comment).

Thanks @Mahdi-Hasan.

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit 9203388)
Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 17f3625cf8ae16ff77938e88de421ba8bd39dffe)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: irc P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants