fix(import): preserve attachment source on security owner stack - #1701
seonghobae wants to merge 4 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (4)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe fixture importer now checks duplicates before and after enrichment, ends read transactions before embedding calls, preserves attachments when attachment embedding fails, and assigns prepared attachments to the email. Tests cover transaction behavior and PostgreSQL persistence. ChangesFixture import integrity
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Bug fix Sequence Diagram(s)sequenceDiagram
participant import_eml_file
participant DatabaseSession
participant EmbeddingService
participant Email
import_eml_file->>DatabaseSession: Check for existing message_id
DatabaseSession-->>import_eml_file: Duplicate status
import_eml_file->>DatabaseSession: Roll back read transaction
import_eml_file->>EmbeddingService: Embed body and attachments
EmbeddingService-->>import_eml_file: Embeddings or attachment failure
import_eml_file->>DatabaseSession: Re-check for duplicate
import_eml_file->>Email: Attach prepared attachments
import_eml_file->>DatabaseSession: Commit fixture
Merge Risk: ⚪ Minimal · up to No actionable merge-blocking risk remains in the reviewed changes. 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai review exact head |
🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo '== HEAD AND ANCESTRY =='
git rev-parse HEAD
git status --short
git merge-base --is-ancestor 3da3ae8e60e1bb049f59ae86bfe82db12b7e3cc7 23ab3653543240c9c194e98530bb793d037489bc && echo 'base-1612-is-ancestor=yes' || echo 'base-1612-is-ancestor=no'
git merge-base --is-ancestor 0b83e7062d0829f4b8b6771242b5b6ed0cd57ac7 23ab3653543240c9c194e98530bb793d037489bc && echo 'predecessor-1699-is-ancestor=yes' || echo 'predecessor-1699-is-ancestor=no'
git merge-base 3da3ae8e60e1bb049f59ae86bfe82db12b7e3cc7 23ab3653543240c9c194e98530bb793d037489bc
git merge-base 0b83e7062d0829f4b8b6771242b5b6ed0cd57ac7 23ab3653543240c9c194e98530bb793d037489bc
echo '== CHANGED PATHS: `#1612` BASE..HEAD =='
git diff --name-status 3da3ae8e60e1bb049f59ae86bfe82db12b7e3cc7 23ab3653543240c9c194e98530bb793d037489bc
echo '== CHANGED PATHS: PROTECTED ANCESTOR..#1612 =='
git diff --name-status 042b0c70531b229af3acbd0421a2f23098d848b3 3da3ae8e60e1bb049f59ae86bfe82db12b7e3cc7
echo '== CHANGED PATHS: PROTECTED ANCESTOR..#1699 =='
git diff --name-status 042b0c70531b229af3acbd0421a2f23098d848b3 0b83e7062d0829f4b8b6771242b5b6ed0cd57ac7
echo '== CANDIDATE FILES =='
fd -a -t f 'import_fixtures\.py|.*import.*fixture.*|.*doctor.*|.*fixture.*test.*|.*import.*test.*' . -E .git | sed -n '1,200p'
echo '== IMPORTER OUTLINE =='
ast-grep outline backend/import_fixtures.py --items all 2>/dev/null || true
echo '== IMPORTER DIFF: `#1612` BASE..HEAD =='
git diff --unified=80 3da3ae8e60e1bb049f59ae86bfe82db12b7e3cc7 23ab3653543240c9c194e98530bb793d037489bc -- backend/import_fixtures.py
echo '== IMPORTER DIFF: PROTECTED ANCESTOR..#1612 =='
git diff --unified=80 042b0c70531b229af3acbd0421a2f23098d848b3 3da3ae8e60e1bb049f59ae86bfe82db12b7e3cc7 -- backend/import_fixtures.py
echo '== IMPORTER DIFF: PROTECTED ANCESTOR..#1699 =='
git diff --unified=80 042b0c70531b229af3acbd0421a2f23098d848b3 0b83e7062d0829f4b8b6771242b5b6ed0cd57ac7 -- backend/import_fixtures.py
echo '== TEST AND DOCTORING DELTA: `#1612` BASE..HEAD =='
git diff --unified=50 3da3ae8e60e1bb049f59ae86bfe82db12b7e3cc7 23ab3653543240c9c194e98530bb793d037489bc -- ':(exclude)backend/import_fixtures.py'
echo '== PR AND CHECK EVIDENCE =='
gh pr view 1701 --repo ContextualWisdomLab/naruon --json number,state,isDraft,headRefOid,baseRefName,commits,statusCheckRollup,reviewDecision,latestReviews,url
gh run list --repo ContextualWisdomLab/naruon --commit 23ab3653543240c9c194e98530bb793d037489bc --limit 30 --json databaseId,name,workflowName,event,status,conclusion,headSha,createdAt,updatedAt,urlLength of output: 45705 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo '== IMPORTER AT EXACT HEAD =='
cat -n backend/import_fixtures.py | sed -n '1,190p'
echo '== ATTACHMENT TEST OUTLINE =='
ast-grep outline backend/tests/test_import_fixture_attachment_integrity.py --items all
echo '== ATTACHMENT TEST REMAINDER =='
cat -n backend/tests/test_import_fixture_attachment_integrity.py | sed -n '1,280p'
echo '== PYTEST CONFIGURATION =='
fd -a -t f 'pyproject\.toml|pytest\.ini|tox\.ini|setup\.cfg|conftest\.py' . -E .git | while read -r file; do
echo "--- $file"
rg -n -C 4 'pytest|markers|postgres|addopts' "$file" || true
done
echo '== DATABASE MODEL CANDIDATES =='
fd -a -t f 'models\.py' backend -E .git
echo '== EMAIL / ATTACHMENT MODEL OUTLINE =='
ast-grep outline backend/db/models.py --items all --match 'Email|Attachment' 2>/dev/null || true
echo '== EMAIL / ATTACHMENT MAPPING AND CASCADE =='
rg -n -C 8 'class (Email|Attachment)\b|attachments\s*=|email_id\s*=|ForeignKey|cascade=' backend/db/models.py
echo '== TEST SELECTION REFERENCES =='
rg -n -C 3 'test_import_fixture_attachment_integrity|pytest.*postgres|postgres.*pytest| -m postgres|--marker' . \
-g '!**/.git/**' -g '!**/node_modules/**' -g '!**/dist/**' | sed -n '1,240p'
echo '== EXACT LOGGING DIFFERENCE: `#1612` BASE VS HEAD =='
git diff --word-diff=plain 3da3ae8e60e1bb049f59ae86bfe82db12b7e3cc7 23ab3653543240c9c194e98530bb793d037489bc -- backend/import_fixtures.py | rg -n -C 2 'except|logger\.(error|warning|info)|Exception' || true
echo '== EFFECTIVE FUNCTIONAL DELTA COMPARISON =='
git diff --ignore-space-at-eol --unified=0 042b0c70531b229af3acbd0421a2f23098d848b3 0b83e7062d0829f4b8b6771242b5b6ed0cd57ac7 -- backend/import_fixtures.py > /tmp/predecessor-importer.diff
git diff --ignore-space-at-eol --unified=0 3da3ae8e60e1bb049f59ae86bfe82db12b7e3cc7 23ab3653543240c9c194e98530bb793d037489bc -- backend/import_fixtures.py > /tmp/successor-importer.diff
echo '-- predecessor functional additions/removals excluding exception/log lines --'
rg -n -v '^[+-].*(except Exception as e|logger\.error|Failed to|Fixture .* failed)' /tmp/predecessor-importer.diff | sed -n '1,220p'
echo '-- successor functional additions/removals excluding exception/log lines --'
rg -n -v '^[+-].*(except Exception:|logger\.error|Fixture .* failed)' /tmp/successor-importer.diff | sed -n '1,220p'Length of output: 60532
I found no blocking source-level defect in the conflict resolution.
The PostgreSQL acceptance is not complete. GitHub reports no workflow run for this exact head. I found only CodeRabbit and Devin Review status contexts. I did not execute repository tests in this inspection. A successful exact-head execution of ✅ Action performedReview finished.
|
Authority
23ab3653543240c9c194e98530bb793d037489bc525d4c42800f5ac2912385d1b18aff5bd83a19f93da3ae8e60e1bb049f59ae86bfe82db12b7e3cc7develop@042b0c70531b229af3acbd0421a2f23098d848b30b83e7062d0829f4b8b6771242b5b6ed0cd57ac7Why this successor exists
#1699 correctly repaired attachment-source loss and transaction ordering, but it was built directly on protected
developwhile #1612 already owns exception-redaction changes in the samebackend/import_fixtures.pyfile. As a result, #1699's current tree reintroduced raw exception interpolation relative to the canonical #1612 security lineage. That is a single-writer/stacking defect, not a reason to discard #1699's valid data-integrity work.This successor starts from unchanged #1612 and reapplies only #1699's valid attachment/transaction/test/doctoring delta. It preserves #1612's static, non-secret failure logging. #1699 remains open as predecessor provenance until this successor or an integrated descendant fully proves succession; do not merge both.
Combined causal repair
The root fixture importer now:
message_idduplication before enrichment;rollback()before model/provider work;embedding=Nonewhen only attachment enrichment fails;Body embedding remains fail-closed. Commit failure still rolls back.
Verification contract
@pytest.mark.postgresacceptance imports through productionimport_eml_file(), reloads the persisted Email/Attachment aggregate, requires source filename/content withembedding=None, deletes the Email, and verifies attachment cascade cleanup.Current evidence boundary
CodeRabbit formally APPROVED exact
23ab3653543240c9c194e98530bb793d037489bcat 2026-09-15T16:59:10Z. This satisfies the independent-review component for the unchanged current head; it does not substitute for executable database/security evidence.Commit-SHA workflow lookup still returns zero repository-local PR workflow runs for this exact head because the PR is stacked on #1612 and the repository-local stacked-PR trigger defect remains owned by #1691. The PostgreSQL test being present is therefore not itself a hosted receipt. Do not fabricate evidence via temporary retargeting, copied workflows, synthetic statuses, or no-op commits.
Gate
Keep Draft. Normal forward path is #1612 protected integration → ordinary retarget/reconciliation of this unchanged effective delta onto protected lineage → exact-head PostgreSQL/migration/security checks → re-evaluate whether the existing unchanged-head approval remains admissible under the then-live merge policy. #1697 closes only after normal integration proves complete succession. No force push, destructive rebase, self-approval, gate weakening, duplicate merge, or scanner suppression.