Skip to content

Commit 8427655

Browse files
authored
Merge pull request #370 from FalkorDB/fix-demo-rules
Fix demo rules usage
2 parents f3dd0a3 + 847c8ea commit 8427655

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

api/routes/graphs.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,13 @@ async def get_graph_user_rules(request: Request, graph_id: str):
255255
async def update_graph_user_rules(request: Request, graph_id: str, data: UserRulesRequest):
256256
"""Update user rules for the specified graph."""
257257
try:
258+
# Prevent modifying rules for demo databases
259+
if GENERAL_PREFIX and graph_id.startswith(GENERAL_PREFIX):
260+
return JSONResponse(
261+
content={"error": "Rules cannot be modified for demo databases"},
262+
status_code=403
263+
)
264+
258265
logging.info(
259266
"Received request to update user rules, content length: %d", len(data.user_rules)
260267
)

app/src/pages/Settings.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ const Settings = () => {
265265
} catch (error) {
266266
toast({
267267
title: "Error",
268-
description: "Failed to save user rules",
268+
description: error instanceof Error ? error.message : "Failed to save user rules",
269269
variant: "destructive",
270270
});
271271
}
@@ -583,7 +583,7 @@ const Settings = () => {
583583
} catch (error) {
584584
toast({
585585
title: "Error",
586-
description: "Failed to save user rules",
586+
description: error instanceof Error ? error.message : "Failed to save user rules",
587587
variant: "destructive",
588588
});
589589
}

app/src/services/database.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ export class DatabaseService {
326326
if (!response.ok) {
327327
const errorData = await response.json().catch(() => ({}));
328328
console.error('Failed to update user rules:', errorData);
329-
throw new Error('Failed to update user rules');
329+
throw new Error(errorData.error || 'Failed to update user rules');
330330
}
331331

332332
const result = await response.json();

0 commit comments

Comments
 (0)