kasuken / kasuken/LearnStack

Add optimistic concurrency (RowVersion) to user-editable entities

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

Nobody has claimed this yet.

enhancement
Dominant language
HTML
Stars
10
Forks
0
Avg merge
2h 52m
Merged PRs (30d)
20

Description

Tier 2 — correctness

Problem

No entity carries a concurrency token, and the update services copy every field from the incoming object onto the tracked entity. Two browser tabs — very common in a Blazor Server app, and the resource list is also edited from dialogs — silently overwrite each other, last write wins. Drag-and-drop reordering makes this worse because it rewrites CustomOrder across many rows at once.

Evidence
  • LearnStack.Core/Data/Models/LearningResource.cs — no RowVersion
  • LearnStack.Core/Services/LearningResourceService.cs:105-130 — wholesale field copy
  • LearnStack.Core/Services/LearningResourceService.cs:157-176 — bulk CustomOrder rewrite
Proposed fix
  1. Add [Timestamp] public byte[]? RowVersion { get; set; } to LearningResource and ContentIdea.
  2. Handle DbUpdateConcurrencyException in the services and surface a "this item changed elsewhere" message instead of silently overwriting.
Acceptance criteria
  • Concurrent edits produce a conflict message rather than silent data loss
  • Reordering is resilient to a stale client-side list

Contributor guide

No contributing guide indexed for this repository

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.

Research direction

Start with LearnStack.Core/Data/Models/LearningResource.cs and LearnStack.Core/Services/LearningResourceService.cs:105-130, then trace the service's bulk reorder path at lines 157-176. Identify the corresponding ContentIdea model and service, and verify how DbUpdateConcurrencyException can reach the user-facing flow. Done means concurrent edits show a conflict message and stale client-side reordering no longer silently loses changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend, databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.