fix: Quote string values in YAML frontmatter to handle special charac… · basicmachines-co/basic-memory@f0d7398 · GitHub
Skip to content

Commit f0d7398

Browse files
fix: Quote string values in YAML frontmatter to handle special characters (#418)
Signed-off-by: phernandez <paul@basicmachines.co> Signed-off-by: Paul Hernandez <60959+phernandez@users.noreply.github.com> Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com> Co-authored-by: Paul Hernandez <phernandez@users.noreply.github.com>
1 parent 581b7b1 commit f0d7398

3 files changed

Lines changed: 109 additions & 76 deletions

File tree

src/basic_memory/file_utils.py

Lines changed: 12 additions & 3 deletions

tests/sync/test_sync_service.py

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1651,79 +1651,6 @@ async def mock_sync_markdown_file(path, new):
16511651
assert entity is not None
16521652

16531653

1654-
@pytest.mark.asyncio
1655-
@pytest.mark.skip("flaky on ci tests")
1656-
async def test_circuit_breaker_tracks_multiple_files(
1657-
sync_service: SyncService, project_config: ProjectConfig
1658-
):
1659-
"""Test that circuit breaker tracks multiple failing files independently."""
1660-
from unittest.mock import patch
1661-
1662-
project_dir = project_config.home
1663-
1664-
# Create multiple files with valid markdown
1665-
await create_test_file(
1666-
project_dir / "file1.md",
1667-
"""
1668-
---
1669-
type: knowledge
1670-
---
1671-
# File 1
1672-
Content 1
1673-
""",
1674-
)
1675-
await create_test_file(
1676-
project_dir / "file2.md",
1677-
"""
1678-
---
1679-
type: knowledge
1680-
---
1681-
# File 2
1682-
Content 2
1683-
""",
1684-
)
1685-
await create_test_file(
1686-
project_dir / "file3.md",
1687-
"""
1688-
---
1689-
type: knowledge
1690-
---
1691-
# File 3
1692-
Content 3
1693-
""",
1694-
)
1695-
1696-
# Mock to make file1 and file2 fail, but file3 succeed
1697-
original_sync_markdown_file = sync_service.sync_markdown_file
1698-
1699-
async def mock_sync_markdown_file(path, new):
1700-
if "file1.md" in path or "file2.md" in path:
1701-
raise ValueError(f"Failure for {path}")
1702-
# file3 succeeds - use real implementation
1703-
return await original_sync_markdown_file(path, new)
1704-
1705-
with patch.object(sync_service, "sync_markdown_file", side_effect=mock_sync_markdown_file):
1706-
# Fail 3 times for file1 and file2 (file3 succeeds each time)
1707-
await force_full_scan(sync_service)
1708-
await sync_service.sync(project_dir) # Fail count: file1=1, file2=1
1709-
await touch_file(project_dir / "file1.md") # Touch to trigger incremental scan
1710-
await touch_file(project_dir / "file2.md") # Touch to trigger incremental scan
1711-
await force_full_scan(sync_service)
1712-
await sync_service.sync(project_dir) # Fail count: file1=2, file2=2
1713-
await touch_file(project_dir / "file1.md") # Touch to trigger incremental scan
1714-
await touch_file(project_dir / "file2.md") # Touch to trigger incremental scan
1715-
report3 = await sync_service.sync(project_dir) # Fail count: file1=3, file2=3, now skipped
1716-
1717-
# Both files should be skipped on third sync
1718-
assert len(report3.skipped_files) == 2
1719-
skipped_paths = {f.path for f in report3.skipped_files}
1720-
assert "file1.md" in skipped_paths
1721-
assert "file2.md" in skipped_paths
1722-
1723-
# Verify file3 is not in failures dict
1724-
assert "file3.md" not in sync_service._file_failures
1725-
1726-
17271654
@pytest.mark.asyncio
17281655
async def test_circuit_breaker_handles_checksum_computation_failure(
17291656
sync_service: SyncService, project_config: ProjectConfig

tests/utils/test_frontmatter_obsidian_compatible.py

Lines changed: 97 additions & 0 deletions

0 commit comments

Comments
 (0)