Answer 404 when a wiki settings change finds no row to update

This commit is contained in:
arc53-machine committed 2026-09-29 16:37:58 +01:00
1 parent c66afd6b30
commit 91e70d2f0c
2 files changed
+19 -4

No files matched your search

+7 -4
View File
@@ -1091,8 +1091,8 @@ class WikiSettings(Resource):
@api.doc(
description="Change a wiki's settings (owner only, manage_settings). "
"Body: {\"allow_outside_edits\": bool}: whether runs from the agent's "
"API key, widget or public link may edit the wiki."
"Body: {\"allow_outside_edits\": bool}: whether runs from an agent's "
"API key or widget may edit the wiki."
)
def put(self, source_id):
decoded_token = request.decoded_token
@@ -1118,9 +1118,12 @@ class WikiSettings(Resource):
return make_response(
jsonify({"success": False, "message": "Source is not a wiki"}), 400
)
SourcesRepository(conn).set_wiki_outside_edits(
if not SourcesRepository(conn).set_wiki_outside_edits(
str(doc["id"]), ra.owner_id, allowed
)
):
return make_response(
jsonify({"success": False, "message": "Source not found"}), 404
)
record_event(
conn,
"source.wiki_settings_updated",
@@ -705,3 +705,15 @@ class TestWikiSettings:
)
assert response.status_code == 400
assert self._stored(pg_conn, sid) is False
def test_no_row_updated_is_404(self, app, pg_conn):
sid = self._wiki(pg_conn, "alice-ws-gone")
with patch(
"docsgpt.storage.db.repositories.sources.SourcesRepository.set_wiki_outside_edits",
return_value=False,
):
response = _settings_call(
app, pg_conn, sid, "alice-ws-gone", "PUT", {"allow_outside_edits": True}
)
assert response.status_code == 404
assert response.json["success"] is False