Commit 997658b
feat: add overwrite option to ha_import_blueprint for blueprint re-import (#1897)
* feat: add overwrite option to ha_import_blueprint for re-import
ha_import_blueprint failed with "File already exists" when the blueprint
was already installed, because blueprint/save was called without
allow_override. Add an overwrite parameter (default false) that passes
allow_override to blueprint/save, giving parity with the UI's
"Re-import blueprint" action including the automatic reload of
automations/scripts that use the blueprint.
When the blueprint exists and overwrite is not set, fail early with a
structured RESOURCE_ALREADY_EXISTS error pointing at overwrite=true,
using the exists flag already returned by blueprint/import.
Closes #1894
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018jyfbxjiBfZ97BLUDseDzW
* fix: surface blueprint validation errors and harden re-import error paths
Review findings on the overwrite feature:
- blueprint/import validation_errors (min-version check) were silently
discarded and blueprint/save never re-runs them, so an unsupported
blueprint saved cleanly and reported success - with overwrite=true it
would replace a working blueprint and reload its consumers. Fail the
import with VALIDATION_FAILED instead.
- The save-time "already exists" fallback (import/save race, or an
installed file that fails to load) now raises RESOURCE_ALREADY_EXISTS
like the early check, so agents see one code for one condition.
- allow_override is only sent when overwrite=true; the WS schema on
HA < 2023.12 rejects unknown keys.
New e2e coverage: re-import with changed served content verifies the new
content actually lands (the issue #1894 user story), overwrite=true on a
fresh import installs without reporting an override, and an impossible
min_version blueprint is rejected at import. Both blueprint fixtures now
expose their writable served directory to make that possible.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018jyfbxjiBfZ97BLUDseDzW
---------
Co-authored-by: kingpanther13 <kingpanther13@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>1 parent 86b94f4 commit 997658b
3 files changed
Lines changed: 330 additions & 34 deletions
File tree
- src/ha_mcp/tools
- tests/src/e2e
- workflows/blueprints
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
222 | 222 | | |
223 | 223 | | |
224 | 224 | | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 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 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
225 | 287 | | |
226 | 288 | | |
227 | 289 | | |
| |||
240 | 302 | | |
241 | 303 | | |
242 | 304 | | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
243 | 313 | | |
244 | 314 | | |
245 | 315 | | |
246 | 316 | | |
247 | 317 | | |
248 | | - | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
249 | 322 | | |
250 | 323 | | |
251 | 324 | | |
252 | 325 | | |
253 | 326 | | |
| 327 | + | |
254 | 328 | | |
255 | 329 | | |
256 | 330 | | |
| |||
260 | 334 | | |
261 | 335 | | |
262 | 336 | | |
| 337 | + | |
263 | 338 | | |
264 | 339 | | |
265 | 340 | | |
| |||
328 | 403 | | |
329 | 404 | | |
330 | 405 | | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | | - | |
346 | | - | |
347 | | - | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
348 | 422 | | |
349 | 423 | | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | | - | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
358 | 428 | | |
359 | 429 | | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
364 | 442 | | |
365 | 443 | | |
366 | 444 | | |
367 | | - | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
368 | 450 | | |
369 | 451 | | |
370 | 452 | | |
| |||
375 | 457 | | |
376 | 458 | | |
377 | 459 | | |
378 | | - | |
379 | | - | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
380 | 466 | | |
381 | 467 | | |
382 | 468 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1450 | 1450 | | |
1451 | 1451 | | |
1452 | 1452 | | |
1453 | | - | |
| 1453 | + | |
| 1454 | + | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
1454 | 1459 | | |
1455 | 1460 | | |
1456 | 1461 | | |
| |||
1471 | 1476 | | |
1472 | 1477 | | |
1473 | 1478 | | |
| 1479 | + | |
1474 | 1480 | | |
1475 | 1481 | | |
1476 | 1482 | | |
| |||
0 commit comments