Skip to content

Commit 6d917f5

Browse files
committed
Merge branch 'fix/remove-file-hash-from-error' into develop
2 parents ee30083 + a62cea2 commit 6d917f5

File tree

3 files changed

+7
-13
lines changed

3 files changed

+7
-13
lines changed

src/mcp_text_editor/text_editor.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ async def edit_file_contents(
225225
return {
226226
"result": "error",
227227
"reason": "File not found and non-empty hash provided",
228-
"file_hash": None,
229228
"content": None,
230229
}
231230
# Create parent directories if they don't exist
@@ -237,7 +236,6 @@ async def edit_file_contents(
237236
return {
238237
"result": "error",
239238
"reason": f"Failed to create directory: {str(e)}",
240-
"file_hash": None,
241239
"content": None,
242240
}
243241
# Initialize empty state for new file
@@ -267,7 +265,6 @@ async def edit_file_contents(
267265
return {
268266
"result": "error",
269267
"reason": "FileHash mismatch - Please use get_text_file_contents tool to get current content and hashes, then retry with the updated hashes.",
270-
"file_hash": None,
271268
"content": None,
272269
}
273270
else:
@@ -377,7 +374,6 @@ async def edit_file_contents(
377374
return {
378375
"result": "error",
379376
"reason": "Content range hash mismatch - Please use get_text_file_contents tool to get current content and hashes, then retry with the updated hashes.",
380-
"file_hash": None,
381377
"content": current_content,
382378
}
383379

@@ -423,7 +419,6 @@ async def edit_file_contents(
423419
return {
424420
"result": "error",
425421
"reason": f"Error editing file: {str(e)}",
426-
"file_hash": None,
427422
"content": None,
428423
}
429424
except Exception as e:
@@ -434,6 +429,5 @@ async def edit_file_contents(
434429
return {
435430
"result": "error",
436431
"reason": "Unexpected error occurred",
437-
"file_hash": None,
438432
"content": None,
439433
}

tests/test_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ async def test_edit_contents_handler_partial_failure(tmp_path):
314314
nonexistent_path = str(tmp_path / "nonexistent.txt")
315315
assert edit_results[nonexistent_path]["result"] == "error"
316316
assert "File not found" in edit_results[nonexistent_path]["reason"]
317-
assert edit_results[nonexistent_path]["file_hash"] is None
317+
assert "file_hash" not in edit_results[nonexistent_path]
318318

319319

320320
@pytest.mark.asyncio

tests/test_text_editor.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ async def test_directory_creation_error(editor, tmp_path, mocker):
5757

5858
assert result["result"] == "error"
5959
assert "Failed to create directory" in result["reason"]
60-
assert result["file_hash"] is None
60+
assert "file_hash" not in result
6161

6262

6363
@pytest.mark.asyncio
@@ -376,7 +376,7 @@ async def test_directory_creation_failure(editor, tmp_path):
376376

377377
assert result["result"] == "error"
378378
assert "Failed to create directory" in result["reason"]
379-
assert result["file_hash"] is None
379+
assert "file_hash" not in result
380380

381381

382382
@pytest.mark.asyncio
@@ -429,7 +429,7 @@ def mock_makedirs(*args, **kwargs):
429429
assert result["result"] == "error"
430430
assert "Failed to create directory" in result["reason"]
431431
assert "Permission denied" in result["reason"]
432-
assert result["file_hash"] is None
432+
assert "file_hash" not in result
433433
assert result["content"] is None
434434

435435

@@ -487,7 +487,7 @@ async def test_file_write_permission_error(editor, tmp_path):
487487
assert result["result"] == "error"
488488
assert "Error editing file" in result["reason"]
489489
assert "Permission" in result["reason"]
490-
assert result["file_hash"] is None
490+
assert "file_hash" not in result
491491
assert result["content"] is None
492492

493493

@@ -565,7 +565,7 @@ async def test_new_file_with_non_empty_hash(editor, tmp_path):
565565
# Verify proper error handling
566566
assert result["result"] == "error"
567567
assert "File not found and non-empty hash provided" in result["reason"]
568-
assert result["file_hash"] is None
568+
assert "file_hash" not in result
569569
assert result["content"] is None
570570

571571

@@ -618,7 +618,7 @@ def mock_makedirs(*args, **kwargs):
618618
assert result["result"] == "error"
619619
assert "Failed to create directory" in result["reason"]
620620
assert "Permission denied" in result["reason"]
621-
assert result["file_hash"] is None
621+
assert "file_hash" not in result
622622
assert result["content"] is None
623623

624624

0 commit comments

Comments
 (0)