Bug fix: Underscores are not allowed in batch IDs as per the batch spec#165
Conversation
From https://ircv3.net/specs/extensions/batch > The reference tag MUST be treated as an opaque identifier. Reference tag MUST contain only ASCII letters, numbers, and/or hyphen, and MUST be case-sensitive.
|
Automated deployment preview for the PR in the Cloudflare Pages. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/lib/messageProtocol.ts (1)
89-91: Good fix for IRC batch spec compliance.The change from underscores to hyphens correctly addresses the specification requirement that batch reference tags must only contain ASCII letters, numbers, and hyphens.
One optional cleanup:
substris deprecated. Consider usingsubstringorsliceinstead.,
♻️ Optional: Replace deprecated substr
export const createBatchId = (): string => { - return `ml-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`; + return `ml-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`; };🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/lib/messageProtocol.ts` around lines 89 - 91, The createBatchId function uses the deprecated String.prototype.substr; update createBatchId to use a non-deprecated alternative (e.g., String.prototype.slice or String.prototype.substring) when truncating the Math.random().toString(36) output so the generated tag still uses the same 9-character portion; keep the existing template format (`ml-${Date.now()}-${...}`) and hyphen usage unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/lib/messageProtocol.ts`:
- Around line 89-91: The createBatchId function uses the deprecated
String.prototype.substr; update createBatchId to use a non-deprecated
alternative (e.g., String.prototype.slice or String.prototype.substring) when
truncating the Math.random().toString(36) output so the generated tag still uses
the same 9-character portion; keep the existing template format
(`ml-${Date.now()}-${...}`) and hyphen usage unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 6f48811d-18d0-4253-adaf-10cf1707dc46
📒 Files selected for processing (1)
src/lib/messageProtocol.ts
This is not needed and actually interferes with multiline-concat, which results in missing spaces.
📝 WalkthroughWalkthroughModified Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/lib/messageProtocol.ts (1)
90-90: Replace deprecatedsubstrwithslicein batch ID generation.
substris deprecated (Annex B only, non-standard) and should be replaced withslice, which is part of the core ECMAScript spec. The conversionsubstr(2, 9)→slice(2, 11)is correct.♻️ Proposed refactor
-export const createBatchId = (): string => { - return `ml-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`; -}; +export const createBatchId = (): string => { + return `ml-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`; +};🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/lib/messageProtocol.ts` at line 90, The batch ID generation uses deprecated String.prototype.substr; update the expression in the function that returns the ID (the line returning `ml-${Date.now()}-${...}`) to use slice instead of substr and adjust the end index accordingly (change `substr(2, 9)` to `slice(2, 11)`) so the generated ID length remains the same and avoids the non-standard API.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/lib/messageProtocol.ts`:
- Line 90: The batch ID generation uses deprecated String.prototype.substr;
update the expression in the function that returns the ID (the line returning
`ml-${Date.now()}-${...}`) to use slice instead of substr and adjust the end
index accordingly (change `substr(2, 9)` to `slice(2, 11)`) so the generated ID
length remains the same and avoids the non-standard API.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 5e7c62ce-31f5-4b6f-a0cd-7254ba27e6ab
📒 Files selected for processing (1)
src/lib/messageProtocol.ts
|
please merge asap |
|
you can't do it? |
we have a policy for reviewing before merging, and another dev must review it before a pull request can be merged. so no |
From https://ircv3.net/specs/extensions/batch
Discovered thanks to UnrealIRCd's implementation which correctly told us we're doing it wrong. Means Ergo has a bug.
Summary by CodeRabbit