Repository navigation
group: one live group per name under a parent - #100
Merged
Merged
Conversation
v2 refused a second live group of one name under one parent. v3 accepted it on create, rename, move and restore. The check runs under the group name lock api#99 added, so concurrent writers can't both win on mysql. The zone_record route fixture made a second top-level group named route.example.com. It gets a name of its own and cleans up after itself. The username race test's groups no longer share a parent, so its rename fails only on the username.
There was a problem hiding this comment.
🟡 Changes recommended
Legacy JSON/TOML groups are returned without parent_gid rather than normalized to parent_gid: 0, leaving their shape inconsistent with newly created top-level groups and MySQL.
1 open issue
What changed in this PR
This PR restores v2’s live sibling group-name uniqueness rule across MySQL, JSON, and TOML stores, while allowing deleted groups’ names to be reused.
Changes:
- Reject conflicting creates, renames, moves, and restores, with MySQL checks protected by the group-name lock.
- Default parentless file-store creates to parent
0and treat missing parents as0when filtering. - Add conflict and concurrency tests, preserve parent-only moves with legacy duplicate logins, and isolate route fixtures.
| File | Description |
|---|---|
test/fixtures.js |
Clean up stale zone-record test fixtures. |
routes/zone_record.test.js |
Use a distinct group name and clean up group/user fixtures. |
lib/user/test/mysql.js |
Keep the username race test independent of sibling-name conflicts. |
lib/group/test/mysql.js |
Test concurrent name claims and legacy group moves. |
lib/group/test/index.js |
Test sibling conflicts, parent defaults, and deleted-name reuse. |
lib/group/store/mysql.js |
Enforce sibling-name uniqueness within locked transactions. |
lib/group/store/file.js |
Add sibling checks and top-level parent handling. |
lib/group/store/base.js |
Share sibling-name detection and conflict errors. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Live sibling groups could share a name. Create, rename, move, and restore all allowed it. Each now returns 409 across mysql, json, and toml. Deleted siblings do not hold a name, and restore fails while a live sibling has it. A move of parent_gid alone skips the username check, so groups with duplicate logins in an upgraded db still move.
On mysql, the check runs in the write transaction under api#99's group-name lock. A race test runs four concurrent creates of one name under one parent, and one wins. Moving the check ahead of the lock let two or three win. The json and toml stores now save parent_gid 0 on parentless creates and read missing parent_gid as 0, matching mysql.
A create under a missing parent now answers 400 on every store and writes nothing. Before, mysql committed the group, then failed on its subgroup link and left it with no permission row. On mysql, the group and its ancestor links now commit in one transaction. The ancestor rows are locked before the name lock, the order a rename takes them in. json and toml now ignore trailing spaces when comparing names, as mysql does, and return parent_gid 0 for a group stored without one.
The zone_record route fixture made a second top-level route.example.com group. It now uses its own name and destroys its group and user. Global teardown also drops the old group for reused dev databases. The api#99 username race test put both groups under one parent, where its rename now fails on the sibling check alone. Its second group moved under the first.