Commit 31ff6b1
committed
fix: narrow RuntimeError catch, add search validation, bridge only when needed
Addresses bot review feedback on PR AstrBotDevs#8323:
- Add _needs_bridge() helper to activate temp file bridge only on
Windows + non-ASCII paths (Sourcery AstrBotDevs#5)
- _read_index: re-raise RuntimeError when bridging not needed,
preventing silent swallowing of genuine Faiss errors (Sourcery AstrBotDevs#1)
- _write_index: skip temp file for ASCII/non-Windows paths (Sourcery AstrBotDevs#5)
- search(): validate ndim==1 and dimension before reshape,
preventing silent semantic corruption on 2D input (Sourcery AstrBotDevs#3, AstrBotDevs#4)
- _safe_temp_dir & _make_temp_file: simplify (Sourcery AstrBotDevs#6, AstrBotDevs#7)
- Remove redundant CWD fallback (never reached on non-ASCII paths)
- Remove redundant UUID prefix (mkstemp O_EXCL guarantees uniqueness)
All changes tested: 119/119 pass covering bridge logic,
ASCII/non-ASCII paths, concurrent temp file uniqueness,
search validation, and exception propagation.1 parent 5106dcf commit 31ff6b1
1 file changed
Lines changed: 32 additions & 23 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | 10 | | |
12 | 11 | | |
13 | 12 | | |
| |||
18 | 17 | | |
19 | 18 | | |
20 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
21 | 25 | | |
22 | 26 | | |
23 | 27 | | |
24 | 28 | | |
25 | | - | |
| 29 | + | |
26 | 30 | | |
27 | | - | |
28 | | - | |
| 31 | + | |
29 | 32 | | |
30 | 33 | | |
31 | | - | |
32 | 34 | | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
39 | 38 | | |
40 | | - | |
41 | | - | |
42 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
43 | 42 | | |
44 | 43 | | |
45 | | - | |
46 | | - | |
| 44 | + | |
| 45 | + | |
47 | 46 | | |
48 | 47 | | |
49 | 48 | | |
50 | 49 | | |
51 | 50 | | |
52 | 51 | | |
53 | | - | |
| 52 | + | |
54 | 53 | | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
| 54 | + | |
60 | 55 | | |
61 | 56 | | |
62 | 57 | | |
| |||
78 | 73 | | |
79 | 74 | | |
80 | 75 | | |
81 | | - | |
| 76 | + | |
| 77 | + | |
82 | 78 | | |
83 | 79 | | |
84 | 80 | | |
| |||
98 | 94 | | |
99 | 95 | | |
100 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
139 | 148 | | |
140 | 149 | | |
141 | 150 | | |
| |||
0 commit comments