Summary
Platform link creation determines the next display order using a read-before-write workflow that is not transactionally protected.
Concurrent requests can assign the same display order to multiple links.
Affected Files
- profileService.ts
- schema.prisma
Root Cause
The creation flow calculates the current maximum display order and then inserts a new record separately.
Concurrent requests can observe the same maximum value and both create links using identical display orders.
No transactional enforcement or uniqueness constraint prevents this condition.
Reproduction
- Create multiple platform-link creation requests simultaneously for the same user.
- Allow both requests to execute concurrently.
- Inspect the resulting displayOrder values.
- Observe duplicate ordering assignments.
Expected Behavior
Each newly created platform link should receive a unique display order.
Actual Behavior
Concurrent requests can generate duplicate display orders.
Why This Is Difficult To Detect
Sequential testing behaves correctly.
The issue only appears under concurrent request execution.
Production Impact
- Unstable link ordering
- Ambiguous reorder behavior
- Inconsistent profile rendering
- Persistent ordering corruption
Suggested Fix
Protect display-order assignment with transactional guarantees or enforce uniqueness and retry behavior.
Severity
High
Summary
Platform link creation determines the next display order using a read-before-write workflow that is not transactionally protected.
Concurrent requests can assign the same display order to multiple links.
Affected Files
Root Cause
The creation flow calculates the current maximum display order and then inserts a new record separately.
Concurrent requests can observe the same maximum value and both create links using identical display orders.
No transactional enforcement or uniqueness constraint prevents this condition.
Reproduction
Expected Behavior
Each newly created platform link should receive a unique display order.
Actual Behavior
Concurrent requests can generate duplicate display orders.
Why This Is Difficult To Detect
Sequential testing behaves correctly.
The issue only appears under concurrent request execution.
Production Impact
Suggested Fix
Protect display-order assignment with transactional guarantees or enforce uniqueness and retry behavior.
Severity
High