Commit 625a47f
fix(/mine): address Copilot review on #1
Three findings from Copilot's review pass:
1. **Path-join normalization** (Copilot main.py:223). _translate_client_path
built the rewrite via raw string concatenation; mismatched trailing
slashes between client_prefix and daemon_prefix could produce paths
like "/mnt/raid/ccprojects/-x". Strip exactly one trailing /
from daemon_prefix, lstrip from suffix, join with explicit "/" so
the result is a single separator regardless of operator slash style.
2. **Type validation in /mine** (Copilot main.py:1068). `directory`
comes from JSON and could be a number / object / list, which would
raise on _translate_client_path().startswith and surface as 500.
Add isinstance(directory, str) guard returning a clean 400.
3. **Test determinism for _parse_path_map** (Copilot
tests/test_path_translation.py:31). The previous test passed
_parse_path_map(None) and assumed env was unset, but None used to
mean "read env." Replace the None default with a private sentinel
(_PATH_MAP_USE_ENV) so:
- _parse_path_map() — read env (sentinel default)
- _parse_path_map(None) — no mapping
- _parse_path_map(str) — parse this
Updated tests are split: one for explicit None == empty, one for
no-arg + cleared env == empty, one for no-arg + set env == parsed.
New tests:
- test_explicit_none_returns_empty
- test_env_unset_no_arg_returns_empty
- test_join_normalizes_mismatched_trailing_slash (4 cases: each combo
of trailing/no-trailing slash on client and daemon prefix)
13 tests pass:
python -m unittest tests.test_path_translation -v
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 6c8567f commit 625a47f
2 files changed
Lines changed: 78 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
176 | 176 | | |
177 | 177 | | |
178 | 178 | | |
179 | | - | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
180 | 187 | | |
181 | 188 | | |
182 | 189 | | |
183 | 190 | | |
184 | 191 | | |
185 | 192 | | |
186 | 193 | | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
187 | 199 | | |
188 | 200 | | |
189 | 201 | | |
190 | 202 | | |
191 | | - | |
| 203 | + | |
192 | 204 | | |
193 | 205 | | |
194 | 206 | | |
| |||
217 | 229 | | |
218 | 230 | | |
219 | 231 | | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
220 | 236 | | |
221 | 237 | | |
222 | 238 | | |
223 | | - | |
| 239 | + | |
| 240 | + | |
224 | 241 | | |
225 | 242 | | |
226 | 243 | | |
| |||
1061 | 1078 | | |
1062 | 1079 | | |
1063 | 1080 | | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
1064 | 1086 | | |
1065 | 1087 | | |
1066 | 1088 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | | - | |
32 | 31 | | |
33 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
34 | 39 | | |
35 | 40 | | |
36 | 41 | | |
| |||
57 | 62 | | |
58 | 63 | | |
59 | 64 | | |
| 65 | + | |
| 66 | + | |
60 | 67 | | |
61 | | - | |
| 68 | + | |
62 | 69 | | |
63 | 70 | | |
64 | 71 | | |
65 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
66 | 77 | | |
67 | 78 | | |
68 | 79 | | |
| |||
106 | 117 | | |
107 | 118 | | |
108 | 119 | | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
109 | 159 | | |
110 | 160 | | |
111 | 161 | | |
0 commit comments