Commit 31ab176
fix(api): canonicalize sync-file paths before indexing
Review fixes for the #581 recovery endpoint:
- The sync-file endpoint indexed the caller-supplied path verbatim. On
case-insensitive filesystems (macOS/Windows) a wrong-cased path like
'notes/Disk-Note.md' passes the existence check for 'notes/disk-note.md',
misses the DB row keyed by the on-disk path, and inserts a duplicate
entity under the wrong-cased path. The endpoint now rejects non-normalized
segments ('./', '//') with 400 and canonicalizes the path by matching real
directory entries (exact name first, then a unique case-insensitive match),
so the index lookup and sync always use the on-disk casing. Behavior is
identical on case-sensitive and case-insensitive filesystems.
- Document the automatic single-file disk recovery in the edit_note
docstring.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: phernandez <paul@basicmachines.co>1 parent 787896e commit 31ab176
3 files changed
Lines changed: 149 additions & 9 deletions
File tree
- src/basic_memory
- api/v2/routers
- mcp/tools
- tests/api/v2
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
13 | 16 | | |
14 | 17 | | |
15 | 18 | | |
| |||
242 | 245 | | |
243 | 246 | | |
244 | 247 | | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
245 | 282 | | |
246 | 283 | | |
247 | 284 | | |
| |||
262 | 299 | | |
263 | 300 | | |
264 | 301 | | |
265 | | - | |
266 | | - | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
267 | 305 | | |
268 | 306 | | |
269 | 307 | | |
| |||
279 | 317 | | |
280 | 318 | | |
281 | 319 | | |
282 | | - | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
283 | 336 | | |
284 | 337 | | |
285 | 338 | | |
286 | | - | |
| 339 | + | |
287 | 340 | | |
288 | 341 | | |
289 | 342 | | |
| |||
292 | 345 | | |
293 | 346 | | |
294 | 347 | | |
295 | | - | |
| 348 | + | |
296 | 349 | | |
297 | | - | |
| 350 | + | |
298 | 351 | | |
299 | 352 | | |
300 | 353 | | |
301 | 354 | | |
302 | | - | |
303 | | - | |
| 355 | + | |
304 | 356 | | |
305 | 357 | | |
306 | 358 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
375 | 375 | | |
376 | 376 | | |
377 | 377 | | |
378 | | - | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
379 | 381 | | |
380 | 382 | | |
381 | 383 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1034 | 1034 | | |
1035 | 1035 | | |
1036 | 1036 | | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
1037 | 1123 | | |
1038 | 1124 | | |
1039 | 1125 | | |
| |||
0 commit comments