[Bug]: updateUser saves part of an edit when a later field fails

Open
#112 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
Half a day
Newbie friendliness
48/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust
Domain
backend

Research direction

Start by reading src/api/users.rs lines 213-254, where updateUser writes username, admin flag and permissions one by one and only checks the new password at the end. Then look at how other handlers in the repo open a transaction and do the admin-count check. Done means all validation happens before any write, and the writes plus admin check run in one transaction, with a test showing a rejected password leaves the rename unsaved.

Written by the indexing model from the issue text.

Description

bug

[!NOTE]
This issue was written by Claude (Claude Opus 5.5) from a code review session with @PhrolovaMoe. It was found by reading the code and hasn't been reproduced on a running server.

Version

0.40.0 (feat/desktop, 017a837b)

Area

Other

What happened?

updateUser writes the username, admin flag and permissions one by one, and only validates the new password at the end (src/api/users.rs:213–src/api/users.rs:254). A too-short password returns an error but the other changes are already saved. Nothing runs in a transaction, so two admins demoting each other at once can both pass the "at least one admin" check.

Steps to reproduce

Rename a user and set a 3-character password in the same edit: you get an error, but the rename went through.

Expected behavior

Either the whole edit applies or none of it does.

Suggested fix

Validate every field before writing anything, and do the writes (including the admin count check) in one transaction.

Dominant language
TypeScript
Stars
4
Forks
1
Avg merge
4h 49m
Merged PRs (30d)
5

Getting set up

  • Ships a Dockerfile or Docker Compose file
  • No pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from tinystream-dev/tinystream

All issues in tinystream-dev/tinystream

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.