Skip to content

[Backend] Guard against division-by-zero in createStream controller endTime calculation #507

@ogazboiz

Description

@ogazboiz

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

Why this matters

createStream in backend/src/controllers/stream.controller.ts (line ~80) computes:

endTime: parseInt(startTime) + Number(BigInt(depositedAmount) / BigInt(ratePerSecond))

If ratePerSecond is "0", BigInt("0") divisor throws RangeError: Division by zero, which falls into the generic catch and returns a 500. This endpoint (POST /v1/streams) currently has no validation middleware wired (the createStreamSchema regex ^\d+$ would still allow "0" even once wired in #452), and no try/parse guard on the inputs, so malformed bodies crash with an opaque 500.

This is the same class of bug as the indexer div-by-zero (#450) but in a different file and code path.

Acceptance criteria

Files to touch

  • backend/src/controllers/stream.controller.ts

Out of scope

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programbackendBackend related tasksbugSomething isn't working

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