Repository navigation
Fix: saving an existing private key returned a 500 - #57
Merged
Merged
Conversation
set_private_record used store.add, which only inserts: for a key that already has a row it raises EntryAlreadyExists, so admins could create a private key (e.g. hordes_join) once but every later save in the admin Private tab failed with a 500. Use store.overwrite, which inserts or replaces. Adds a regression test that saves the same key twice. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jefryelb
force-pushed
the
feature/fotos-write-role
branch
from
October 17, 2026 12:25
0fd3708 to
b9b341e
Compare
Contributor
Author
✅ Tested on demo (2026-10-17)Deployed to demo.dsavdodeka.nl together with #58. For the test window, both PRs were merged into a temporary branch, which has since been deleted.
Afterwards the server was restored. |
tiptenbrink
approved these changes
Oct 18, 2026
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.
TL;DR
Saving a private key that already exists always failed with a 500. This PR makes the save replace the existing record. It's a one-line fix plus a regression test.
Context
The private store (
privatetable, added in3b0b6da) holds small admin-managed JSON content such ashordes_join. Admins edit it in/admin→ Private: load the key, edit the JSON, click Save. Each save sends the whole JSON document again.set_private_recordused freetser'sstore.add, which only inserts. When the key already has a row, it raisesEntryAlreadyExists, which surfaces as a 500. So:The handler clearly intended updates (
admin_set_private_handlerreads the existing record to keep its role). Only the storage call was wrong, and no test saved a key twice.Fix
set_private_recordnow usesstore.overwrite, which inserts the row if it's missing and replaces it otherwise. freetser provides it for exactly this case.Verification
tests/test_private_kv.pysaveshordes_jointwice through/admin/private_kv/set/. The second save returns 200, keeps the read role, and members read the new value. Without the fix, the second save returns a 500.uv run ty check,uv run ruff formatanduv run ruff checkall pass.uv run pytest: 44 passed, 2 skipped.BACKEND_PRIVATE_LOCALHOST=1 FAROE_PRIVATE_HOST=127.0.0.1 uv run pytest.Note
This PR first contained a larger change: letting committees write through the private store. That work moved to #58, which gives committees their own tables. This PR now holds only the bug fix found along the way: one commit, two files.
🤖 Generated with Claude Code