Skip to content

Make the maximum IRC line length configurable (max-line-len) - #2456

Closed
kevinpostal wants to merge 1 commit into
ergochat:masterfrom
kevinpostal:pr/max-line-len
Closed

kevinpostal wants to merge 1 commit into
ergochat:masterfrom
kevinpostal:pr/max-line-len

Conversation

@kevinpostal

Copy link
Copy Markdown

Follow-up cleanup for the configurable maximum IRC line length, extracted from waveplate/ergo branch ts6-linking (commit 011144f, author @waveplate).

What this commit does (verified against the diff):

  • Renames SplitMessage.Is512() to SplitMessage.IsSingleLine() in irc/utils/text.go and updates all callers (irc/client.go, irc/handlers.go, irc/message_cache.go, irc/responsebuffer.go, irc/webpush/webpush.go). The old name baked the 512-byte assumption into the API; the new name reflects what it actually tests (sm.Split == nil).
  • Adds a new constant in irc/utils/text.go:
    const (
        // MaxLineLen is the maximum IRC line length, not including tags
        MaxLineLen = 4096
    )
    and uses it for web-push line serialization/parsing (irc/webpush/webpush.go, irc/webpush/webpush_test.go) instead of the hardcoded 512.

Context: the server.max-line-len config key itself (default 512, floored at DefaultMaxLineLen = 512 in irc/client.go, clamped in irc/config.go) is already on master; this commit is the remaining piece from the linking work that decouples the split-message fast path and the webpush path from the 512-byte assumption. Motivation is supporting longer lines for modern clients and the server-linking work, where linked servers may exchange lines longer than the classic 512 bytes.

Testing: make test (gencapdefs check, gofmt check, vet, unit tests) passes locally on this branch. make irctest was NOT run (needs the irctest harness).

Author credit: @waveplate — cherry-picked verbatim, authorship preserved.

Copilot AI lite review requested due to automatic review settings September 20, 2026 05:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Webpush strict serialization is now hard-capped at 4096 via utils.MaxLineLen, which can break configurations (or linked-server messages) where server.max-line-len exceeds 4096, undermining configurability.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Medium severity · 2 Low severity

Open (3)
What changed in this PR

This PR removes the hard-coded 512-byte assumption from SplitMessage call sites and the webpush serialization/parsing path, as part of making IRC max line length configurable.

Changes:

  • Renames SplitMessage.Is512() to SplitMessage.IsSingleLine() and updates all callers.
  • Introduces utils.MaxLineLen (4096) and uses it for webpush message line serialization/parsing instead of a literal 512.
  • Updates the webpush unit test to parse with the new max line length constant.
File Description
irc/​utils/​text.go Adds utils.MaxLineLen constant and renames Is512 → IsSingleLine.
irc/​webpush/​webpush.go Uses utils.MaxLineLen for strict line serialization and updates IsSingleLine call site.
irc/​webpush/​webpush_test.go Parses push lines using utils.MaxLineLen.
irc/​client.go Updates split-message fast-path check to IsSingleLine.
irc/​handlers.go Updates split-message length validation to use IsSingleLine.
irc/​message_cache.go Updates split-message fast-path check to IsSingleLine.
irc/​responsebuffer.go Updates split-message fast-path check to IsSingleLine.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread irc/webpush/webpush.go
Comment on lines 111 to 115
// MakePushLine serializes an arbitrary IRC message as a web push message;
// we assume tags were already filtered.
func MakePushLine(pushMessage ircmsg.Message) ([]byte, error) {
if line, err := pushMessage.LineBytesStrict(false, 512); err == nil {
if line, err := pushMessage.LineBytesStrict(false, utils.MaxLineLen); err == nil {
// strip final \r\n
Comment thread irc/utils/text.go
Comment on lines +11 to +14
const (
// MaxLineLen is the maximum IRC line length, not including tags
MaxLineLen = 4096
)
Comment on lines 43 to 47
line := string(lineBytes)
parsed, err := ircmsg.ParseLineStrict(line, false, 512)
parsed, err := ircmsg.ParseLineStrict(line, false, utils.MaxLineLen)
if err != nil {
t.Fatal(err)
}
Comment thread irc/utils/text.go

const (
// MaxLineLen is the maximum IRC line length, not including tags
MaxLineLen = 4096

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see how hardcoding this value here makes sense? See #1222 for context, for example.

@slingamn slingamn closed this Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants