Repository navigation
fix(protocol): reject content topics that do not start with a slash - #1322
Merged
igor-sirotin merged 1 commit intoOct 1, 2026
Merged
igor-sirotin merged 1 commit into
igor-sirotin merged 1 commit into
Conversation
yucazer0
requested review from
Ivansete-status and
igor-sirotin
as code owners
August 15, 2026 15:06
igor-sirotin
force-pushed
the
fix/content-topic-leading-slash
branch
from
October 1, 2026 13:25
8db2fd4 to
f92776d
Compare
igor-sirotin
approved these changes
Oct 1, 2026
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The validation is correct, focused, and adequately covered by tests.
Review effort: Balanced
Findings: None
What changed in this PR
Enforces canonical leading slashes for parsed content topics and updates affected tests.
Changes:
- Rejects malformed content topics missing
/. - Adds regression coverage.
- Corrects existing test fixtures.
| File | Description |
|---|---|
waku/v2/protocol/content_topic.go |
Validates the leading slash. |
waku/v2/protocol/topic_test.go |
Adds regression tests. |
waku/v2/protocol/lightpush/waku_lightpush_test.go |
Corrects a test topic. |
waku/v2/protocol/filter/filter_test.go |
Corrects filter test topics. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
StringToContentTopic splits on / and only reads the parts after the first one, so a string with text before the leading slash is accepted and that text is silently dropped. waku/2/test/proto/extra parses as /2/test/proto/extra, and GetShardFromContentTopic then derives the shard from the wrong application name and version. topic_test.go already covers this intent with waku/1/a/b, but that string is rejected for having too few parts rather than for the missing slash. Require the leading slash, and correct three test content topics that were missing it and were only accepted because of this.
igor-sirotin
force-pushed
the
fix/content-topic-leading-slash
branch
from
October 1, 2026 13:54
f92776d to
026f7c5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
StringToContentTopicsplits the string on/and only reads the parts after the first one:p[0]is never checked, so a string with text before the leading slash is accepted and that text is silently dropped:ContentTopic.String()then returns/2/test/proto/extra, which is not what was passed in, andGetShardFromContentTopicderives the shard from an application name and version that were never intended, so the message ends up on a different pubsub topic.topic_test.goalready covers this intent:but that string is rejected for having 4 parts rather than for the missing slash, so the 5 and 6 part cases are not caught.
This also explains three test content topics in the repository that are missing the leading slash and are only accepted because of this behaviour:
waku/v2/protocol/lightpush/waku_lightpush_test.go:"0/test/1/testTopic/proto"waku/v2/protocol/filter/filter_test.go:"0/test/1/testTopic/proto"and"0/test/1/testTopic1/proto"They read as generation-0 topics but currently parse as
/test/1/testTopic/protowith the0dropped. They are corrected here, since they would otherwise fail with this change. The derived shard is unaffected, because it only depends on the application name and version, which stay the same either way.Changes
StringToContentTopicrejects strings that do not start with/TestStringToContentTopicRequiresLeadingSlashTests
TestStringToContentTopicRequiresLeadingSlashfails on master:and passes with the fix.
waku/v2/protocolandwaku/v2/protocol/lightpushboth pass.Note:
TestFilterSuite/TestUnsubscribeErrorHandlingfails with and without this change in my environment, so it looks unrelated to this fix.