Skip to content

[Backend] Validate publicKey param in getUser controller #538

Description

@ogazboiz

Telegram (ask questions / claim the issue here first): https://t.me/+DOylgFv1jyJlNzM0

Labels: good first issue, backend

getUser in backend/src/controllers/user.controller.ts takes req.params.publicKey and hands it straight to prisma.user.findUnique with no validation.

getUserEvents in the same file already guards its param (if (typeof publicKey !== 'string')), and registerUserSchema validates the Stellar key format (/^G[A-Z2-7]{55}$/). getUser should do the same so a malformed key returns a clean 400 instead of an empty 404 or a wasted DB hit on garbage input.

What the fix has to hold to

  • Missing/non-string publicKey returns 400, not 404
  • Match the validation style already used elsewhere in this file

Done when

  • Missing/non-string publicKey rejected with 400
  • Optionally validate format with StrKey.isValidEd25519PublicKey and 400 on bad format
  • Existing getUser tests pass; add a case for an invalid key
  • Lint + CI green

Where to start
Just getUser in backend/src/controllers/user.controller.ts. Address validation for stream endpoints is out of scope (see #379). Tiny change.

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial Campaign | FWC26Campaign: Official Campaign | FWC26Stellar WaveIssues in the Stellar wave programbackendBackend related tasksgood first issueGood for newcomers

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions