Repository navigation
Commit 2d71979
authored
fix: accept unknown originators in SubscribeTopics cursor (#1983)
Resolves #1982
## Summary
`SubscribeTopics` rejected requests with `CodeInvalidArgument` whenever
a
client's per-topic cursor referenced an originator the node had not yet
indexed (i.e. absent from `gateway_envelopes_latest`). This breaks
legitimate flows:
- `libxmtp` sends cursors containing migrator originator IDs (10, 11)
even
in environments where no migrator has been configured.
- A client may learn of a new originator before a given node has indexed
any of its messages (new nodes, network partitions).
- A client may still hold a cursor for an originator that was removed
long
ago and has no messages on any currently-live node.
The originator set is node-local and lossy — treating a mismatch as a
fatal
client error is the wrong default.
## Change
- Remove the unknown-originator rejection loop in
`validateTopicFilters`.
All other validation (filter count, topic length, vector clock length)
stays in place.
- `buildTopicCursors` already tolerated unknown originators: the
client's
entries pass through unchanged, and `FillMissingOriginators` still seeds
known originators at sequence 0. The downstream
`SelectGatewayEnvelopesByPerTopicCursors` is a `CROSS JOIN LATERAL` on
the client's `(topic, node_id, seq_id)` tuples — entries that don't
match any row contribute nothing.
- `advanceTopicCursors` already handles previously-unknown originators
starting to publish live, so that path needed no change.
## Test plan
- [x] Replaced `TestSubscribeTopics_UnknownOriginatorInCursor`
(previously
asserted rejection) with
`TestSubscribeTopics_AcceptsUnknownOriginatorInCursor`,
which asserts the subscription opens and delivers envelopes from
known originators.
- [x] Added `TestSubscribeTopics_MixedKnownAndUnknownOriginators`:
cursor
mixes a partially caught-up known originator with an unknown one;
catch-up delivers only the unseen messages for the known originator.
- [x] Added `TestSubscribeTopics_AllUnknownOriginatorsInCursor`: all
cursor
entries are unknown; catch-up still delivers messages from known
originators via `FillMissingOriginators`.
- [x] `TestSubscribeTopics_Validation` unchanged — other validation
errors
still return `CodeInvalidArgument`.
- [x] `go test ./pkg/api/message/... -count=1`
- [x] `dev/lint-fix`
<!-- Macroscope's pull request summary starts here -->
<!-- Macroscope will only edit the content between these invisible
markers, and the markers themselves will not be visible in the GitHub
rendered markdown. -->
<!-- If you delete either of the start / end markers from your PR's
description, Macroscope will append its summary at the bottom of the
description. -->
> [!NOTE]
> ### Accept unknown originator IDs in `SubscribeTopics` cursor without
error
> Previously, `validateTopicFilters` rejected cursors containing
originator IDs not known to the node. This removes that check, since
unknown originators simply match no rows downstream and should not block
subscription processing.
>
> - Removes the `knownOriginators` parameter from
[`validateTopicFilters`](https://github.com/xmtp/xmtpd/pull/1983/files#diff-ac39f1802be2ab7789d5ffc0d2344a0d6f82d8b6a85fde0dc434a0069097bcff),
dropping the loop that rejected unknown originator IDs in `LastSeen`
cursors.
> - Moves `validateTopicFilters` to run before the known-originator
lookup, simplifying the handler flow.
> - Behavioral Change: cursors with unknown originator IDs are now
accepted; catch-up queries for those originators return no results
rather than an error.
>
> <!-- Macroscope's review summary starts here -->
>
> <sup><a href="https://app.macroscope.com">Macroscope</a> summarized
426f102.</sup>
> <!-- Macroscope's review summary ends here -->
>
<!-- Macroscope's pull request summary ends here -->
Co-authored-by: xmtp-coder-agent <>1 parent 727266f commit 2d71979
2 files changed
Lines changed: 89 additions & 29 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
71 | 75 | | |
72 | 76 | | |
73 | 77 | | |
| |||
76 | 80 | | |
77 | 81 | | |
78 | 82 | | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| |||
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
149 | 154 | | |
150 | 155 | | |
151 | | - | |
152 | 156 | | |
153 | 157 | | |
154 | 158 | | |
| |||
164 | 168 | | |
165 | 169 | | |
166 | 170 | | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | 171 | | |
173 | 172 | | |
174 | 173 | | |
175 | 174 | | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | 175 | | |
186 | 176 | | |
187 | 177 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
192 | | - | |
| 192 | + | |
193 | 193 | | |
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
200 | | - | |
201 | | - | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
202 | 207 | | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
208 | 211 | | |
209 | | - | |
210 | | - | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
211 | 281 | | |
212 | 282 | | |
213 | 283 | | |
| |||
0 commit comments