Skip to content

[Backend] Fix SSE subscribe controller: deprecated substr, Zod error.errors, missing users param #546

@ogazboiz

Description

@ogazboiz

Telegram: https://t.me/+DOylgFv1jyJlNzM0

Why this matters

backend/src/controllers/sse.controller.ts has three small correctness/consistency issues:

  1. clientId uses Math.random().toString(36).substr(2, 9)String.prototype.substr is deprecated; use slice/substring.
  2. The catch block returns error.errors for ZodErrors, but Zod's error object exposes .issues (.errors is an alias that is being phased out and is empty under newer Zod), so validation 400s may return an empty errors array.
  3. subscribeSchema only parses streams and all, but the /v1/events/subscribe OpenAPI docs advertise a users query param — it is silently dropped here.

Acceptance criteria

  • Replace substr with slice
  • Use error.issues (and/or instanceof z.ZodError) when building the 400 body
  • Either support users in subscribeSchema or remove it from the OpenAPI docs in routes/v1/events.routes.ts

Files to touch

  • backend/src/controllers/sse.controller.ts
  • backend/src/routes/v1/events.routes.ts (if dropping the documented users param)

Out of scope

  • SSE broadcast/heartbeat logic.

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programbackendBackend related tasksbugSomething isn't workinggood first issueGood for newcomers

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions