Skip to content

Commit 2f878a9

Browse files
vishal-balaclaude
andcommitted
fix(mcp): use FORBIDDEN for read-only upsert rejection (RAAE-1607)
Align the read-only write rejection with the FORBIDDEN error code used on the 1604 branch, instead of INVALID_REQUEST. A read-only binding is a permission policy denial (the request is well-formed but not allowed), so FORBIDDEN is the correct category; INVALID_REQUEST remains for malformed/unroutable requests (unknown index, omitted index, bad shapes). Keeps the two stacked branches consistent so they reconcile cleanly when the stack is collected. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent d1f5f03 commit 2f878a9

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

redisvl/mcp/tools/upsert.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ async def upsert_records(
266266
if rt.effective_read_only:
267267
raise RedisVLMCPError(
268268
f"index '{rt.binding_id}' is read-only",
269-
code=MCPErrorCode.INVALID_REQUEST,
269+
code=MCPErrorCode.FORBIDDEN,
270270
retryable=False,
271271
)
272272
index_obj = rt.index

tests/integration/test_mcp/test_upsert_tool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ async def test_upsert_records_rejects_writes_to_read_only_binding(
466466
records=[{"content": "doc", "category": "operations"}],
467467
)
468468

469-
assert exc_info.value.code == MCPErrorCode.INVALID_REQUEST
469+
assert exc_info.value.code == MCPErrorCode.FORBIDDEN
470470

471471

472472
@pytest.mark.asyncio

tests/unit/test_mcp/test_upsert_tool_unit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ async def test_upsert_records_rejects_writes_to_read_only_binding():
509509
with pytest.raises(RedisVLMCPError, match="read-only") as exc_info:
510510
await upsert_records(server, records=[{"content": "alpha doc"}])
511511

512-
assert exc_info.value.code == MCPErrorCode.INVALID_REQUEST
512+
assert exc_info.value.code == MCPErrorCode.FORBIDDEN
513513
# Write policy is enforced before any embedding or backend write.
514514
assert server.index.load_calls == []
515515
assert server.vectorizer.aembed_many_calls == []

0 commit comments

Comments
 (0)