fix(backend): SSE subscribe substr, Zod issues, users param#606
Open
wheval wants to merge 1 commit into
Open
Conversation
Replace deprecated substr, return Zod issues on validation errors, and honor scoped users query subscriptions on /v1/events/subscribe. Closes LabsCrypt#546
Contributor
|
hey, #706 just merged and fixes a broken test-mock pattern that was causing 'Failed Suites' / 'is not a function' / '0 tests' on backend integration tests. please rebase to pick it up: git fetch upstream
git rebase upstream/main
git push --force-with-lease |
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.
Summary
Fixes three correctness issues in the SSE subscribe controller: deprecated
substr, empty Zod validation payloads, and silently ignoredusersquery parameter.Purpose / Motivation
Clients subscribing via
GET /v1/events/subscribecould receive emptyerrorson bad query params (breaking client-side validation UX), and documentedusersfilters had no effect.substris deprecated and should useslicefor stable client IDs.Changes Made
String.prototype.substrwithslicewhen generating SSEclientIdsuffixes.instanceof z.ZodErrorand returnerror.issuesin the 400 body.usersinsubscribeSchemaand add scopeduser:{publicKey}subscriptions (authenticated user plus counterparties on owned streams; arbitrary keys are ignored).How to Test
GET /v1/events/subscribe.streams=not-an-array) and confirm400includes a non-emptyerrorsarray with Zod issue objects.?users=<your-public-key>and confirm the connection opens and subscriptions includeuser:<your-public-key>.?users=<unrelated-public-key>and confirm that key is not added (only allowed counterparties/self).npx vitest run sse.controller --coverage.enabled=falseinbackend/.Breaking Changes
None. Validation
errorsnow populate correctly; previously empty arrays may have masked issues.Related Issues
Closes #546