Skip to content

zone_record: write to the id in the path - #71

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

zone_record: write to the id in the path#71
msimerson merged 1 commit into
NicTool:mainfrom
aberoham:put-path-id

Conversation

@aberoham

@aberoham aberoham commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

PUT /zone_record/{id} writes to the id in the body, not the id in the path.
The handler reads the record named in the URL, finds it, then hands the store a
merge that starts with the path id and spreads the body over it. A body id wins.
The call answers 200 and reports success for a record it never touched.

Two records in one zone, driven through the routes:

before: 7314 address=203.0.113.2
PUT /zone_record/7313 {id: 7314, address: 198.51.100.99} -> 200
after:  7313 address=203.0.113.1   named in the URL, untouched
after:  7314 address=198.51.100.99 never named in the URL

zone_record.PUT forks id to optional. The key reaches the handler. The
zone and nameserver schemas do not list it and answer 400 with "id" is not allowed. Both handlers had the same argument order, so this puts all four
entities on the order group and user already use.

The regression test asserts on the bystander's stored row, since the response
body looks correct either way. Pinning the status code would tie the test to a
schema that accepts the key, so it does not. It fails on main and passes here.
Neither zone nor nameserver had a route test for its update handler. The two
changed lines arrived uncovered. They have a test now. All three stores run
clean: mysql 398, json and toml the file-store subset.

PUT /zone_record/{id} passed the path id first and spread the body over
it, so a body id replaced it. The handler read the record named in the
URL, found it, then wrote to the record named in the body and answered
200.

    before: 7314 address=203.0.113.2
    PUT /zone_record/7313 {id: 7314, address: 198.51.100.99} -> 200
    after:  7313 address=203.0.113.1   named in the URL, untouched
    after:  7314 address=198.51.100.99 never named in the URL

Only zone_record accepts an id in a PUT body. The zone and nameserver
schemas refuse the key, so those two routes answer 400 before the
handler runs. Their argument order matches group and user now, and the
route tests reach their update handlers for the first time.
@msimerson
msimerson merged commit f12de03 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