Commit 94c57cb
authored
fix(ol_dbt_cli): impact reports BREAKING for deleted models still ref()'d (#2446)
* fix(ol_dbt_cli): use merge-base (three-dot) diff semantics for changed-model detection
git_utils.get_changed_files diffed base_ref..HEAD directly (two-dot). Once
base_ref advances past the PR's branch point (other PRs merging to main
while this one is open), models changed BY OTHERS on main leaked into the
PR's changed set, and get_file_at_ref fetched main's newer content as the
"base" -- producing spurious BREAKING alerts for changes the PR never made,
or masking real ones when main's later edit happened to match.
Add resolve_merge_base() and diff/fetch against merge-base(base_ref, HEAD)
instead, matching the three-dot semantics GitHub uses to render PR diffs.
ol-dbt impact now resolves the merge-base once per run and threads it
through to both changed-model detection and base-content fetching so the
two stay consistent. validate --changed-only picks up the fix for free
since it goes through the same get_changed_sql_models -> get_changed_files
path.
Also union in untracked new files (git status --porcelain) by default so
local runs see in-progress new models that haven't been git-added yet; CI
checkouts have none, so this doesn't affect the PR pipeline.
git_utils.py had zero tests. Added a scripted fixture repo (branch, advance
main independently, assert changed set + fetched content) covering
resolve_merge_base, get_changed_files, get_changed_sql_models, and
get_file_at_ref.
* fix(ol_dbt_cli): use -z for git status/diff parsing, fix docstring mismatch
Two issues from PR review:
- Sentry: `git status --porcelain` (no -z) C-escapes/quotes paths with
whitespace or non-ASCII bytes (e.g. `?? "my model.sql"`,
`?? "caf\303\251.sql"`). The naive `line[3:].strip()` parse left the
quotes/escapes in, producing a path that doesn't exist on disk and
silently dropping the file from the changed set. Same class of bug
applied to the `git diff --name-only` calls for tracked files. Switch
all four git invocations in get_changed_files to `-z` (NUL-delimited,
unquoted) output.
- Copilot: get_changed_files' docstring said it returns "tracked files"
but untracked files are included by default (include_untracked=True).
Fixed the wording.
Added a regression test with a space- and unicode-containing filename;
confirmed it fails against the pre-fix parsing (returned mangled paths
like 'my model.sql"') and passes with -z.
* fix(ol_dbt_cli): impact reports BREAKING for deleted models still ref()'d
impact.py's per-model loop looked up each changed stem in sql_file_map
(built from files currently on disk) and silently `continue`d when a
deleted model's stem wasn't found -- so deleting int__combined__users
while three marts still ref() it produced "0 breaking", exit 0. Renames
hit the same skip on the old stem. `ol-dbt impact --model <typo>` also
silently reported success instead of erroring, unlike validate's
--model handling.
Add git_utils.get_deleted_sql_models(), which diffs --diff-filter=D
against the merge-base to map deleted model stems to their last path.
Add _analyse_deleted_model(), which reads the model's column set at the
merge-base and flags BREAKING for every model whose refs still name it
(scanned across all currently-parsed SQL, so it doesn't depend on a
fresh manifest reflecting a state dbt would refuse to compile). Wire it
into the main loop in place of the silent skip, and error loudly (exit
1) when --model doesn't match any on-disk or just-deleted model.
impact.py had zero end-to-end tests. Added a scripted-repo test class
covering: deletion with a surviving consumer (BREAKING, exit 1),
deletion with no remaining consumers (not BREAKING), and an unknown
--model value (exit 1). All three fail against the pre-fix code.1 parent 435c10e commit 94c57cb
3 files changed
Lines changed: 190 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
366 | 367 | | |
367 | 368 | | |
368 | 369 | | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
369 | 423 | | |
370 | 424 | | |
371 | 425 | | |
| |||
618 | 672 | | |
619 | 673 | | |
620 | 674 | | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
621 | 681 | | |
622 | 682 | | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
623 | 686 | | |
624 | 687 | | |
625 | 688 | | |
| |||
680 | 743 | | |
681 | 744 | | |
682 | 745 | | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
683 | 751 | | |
684 | 752 | | |
685 | 753 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
102 | 129 | | |
103 | 130 | | |
104 | 131 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
| 8 | + | |
| 9 | + | |
7 | 10 | | |
8 | 11 | | |
9 | 12 | | |
| |||
481 | 484 | | |
482 | 485 | | |
483 | 486 | | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
0 commit comments