Skip to content

store: reject create conflicts - #69

Merged
msimerson merged 1 commit into
NicTool:mainfrom
aberoham:create-id-conflicts
Aug 30, 2026
Merged

store: reject create conflicts#69
msimerson merged 1 commit into
NicTool:mainfrom
aberoham:create-id-conflicts

Conversation

@aberoham

Copy link
Copy Markdown
Contributor

create() with an id that already existed returned the existing row. 201 Created, the caller's payload silently discarded, and a response body describing a record they never wrote.

POST /zone_record {id: 5196, owner: 'collide.autoinc.example.com.', ...}
-> 201 Created
-> id 5196, owner victim.autoinc.example.com.

The short-circuit was deliberate: suites re-create fixtures by fixed id without cleaning up first. That's now something a caller asks for, create(args, { ifExists: 'return' }), and only the test helpers ask. Everything else gets a 409.

Every store has the pattern, mysql and file alike, so all of them changed and the backends still agree.

A second bug lives in the same lines and gets the same fix: lib/permission/store/mysql.js flattened the nested {user:{id}} payload after looking for an existing row, so two POSTs wrote two nt_perm rows. objectToDb() now runs first, and the check covers user rows as well as group rows.

mysql  404 tests, 404 pass, 0 failed, 0 skipped
json   381 tests, 381 pass, 0 failed, 0 skipped
toml   381 tests, 381 pass, 0 failed, 0 skipped

@msimerson
msimerson merged commit a38225c into NicTool:main Aug 30, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants