Skip to content

fix(reliability): roll back partial filesystem artifact writes - #355

Open
seonghobae wants to merge 7 commits into
mainfrom
fix/artifact-store-partial-write-main-20260811
Open

fix(reliability): roll back partial filesystem artifact writes#355
seonghobae wants to merge 7 commits into
mainfrom
fix/artifact-store-partial-write-main-20260811

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Objective

Prevent the standalone filesystem artifact store from leaving buyer-visible PDF bytes on disk when the matching metadata sidecar fails to persist. Protected main currently writes the PDF first and, on a later metadata write failure, throws while leaving the PDF readable after restart.

Test-first state

This Draft starts intentionally RED at exact test-only head f49825645e516a378219af1f328cef7c82441e07. FileSystemArtifactStorePartialWriteTest uses the existing injectable writer seam to persist the PDF and fail only the metadata write, then requires both files to be absent and getPdf to return empty. Protected main leaves the PDF behind, so this regression must fail before the production repair.

Scope

This is a bounded FileSystemArtifactStore integrity/reliability repair. It does not implement durable deletion receipts, lifecycle locking, distributed fencing, Office conversion, credential/OIDC work, viewer JavaScript, or canonical cross-cutting documentation. Stale broad PR #268 also mentions this artifact-store path, but its only file-local delta is already present on protected main; this PR introduces a new current-base partial-write invariant rather than copying stale ancestry.

Acceptance

Observe exact-head RED -> smallest production rollback fix -> focused regression GREEN -> exact-head mvn -B --no-transfer-progress verify, zero missed owned production coverage and public Javadocs -> CI/Security Scan/SAST/fuzz -> current reviews/threads/live-base refetch. Keep Draft until exact-head GREEN evidence exists. Qualifying independent write-authorized approval remains a separate protected-merge gate.

Summary by CodeRabbit

  • 버그 수정

    • PDF 저장 중 메타데이터 기록에 실패하면 부분적으로 저장된 파일을 자동으로 정리합니다.
    • 정리 작업이 실패하는 경우에도 원래 발생한 오류와 함께 관련 오류 정보가 보존됩니다.
  • 테스트

    • 부분 저장, 롤백, 잔여 파일 처리 동작을 검증하는 테스트를 추가했습니다.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@seonghobae, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 52 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6ff1b260-e2cb-4781-a6a2-fa2584453417

📥 Commits

Reviewing files that changed from the base of the PR and between 90ec7d4 and a6372a3.

📒 Files selected for processing (2)
  • src/main/java/com/clearfolio/viewer/artifact/FileSystemArtifactStore.java
  • src/test/java/com/clearfolio/viewer/artifact/FileSystemArtifactStorePartialWriteTest.java
📝 Walkthrough

Walkthrough

putPdf가 저장 실패 후 부분 파일을 삭제하도록 변경되었습니다. 롤백 실패는 원래 예외의 suppressed 예외로 보존됩니다. 두 실패 시나리오를 검증하는 테스트가 추가되었습니다.

Changes

아티팩트 부분 쓰기 처리

Layer / File(s) Summary
부분 쓰기 롤백 구현
src/main/java/com/clearfolio/viewer/artifact/FileSystemArtifactStore.java
PDF 또는 메타데이터 저장에 실패하면 두 파일을 삭제합니다. 삭제 실패 예외는 원래 쓰기 예외에 suppressed 예외로 추가됩니다.
부분 쓰기 동작 검증
src/test/java/com/clearfolio/viewer/artifact/FileSystemArtifactStorePartialWriteTest.java
메타데이터 저장 실패 시 예외, 파일 삭제, 빈 조회 결과를 검증합니다. 롤백 실패 시 suppressed 예외와 잔여 파일을 검증합니다.

Estimated code review effort: 2 (Simple) | ~15 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목은 부분적으로 저장된 파일시스템 아티팩트 쓰기를 롤백하는 주요 변경 사항을 정확하고 간결하게 설명합니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/artifact-store-partial-write-main-20260811

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@seonghobae
seonghobae marked this pull request as ready for review August 10, 2026 20:15

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/main/java/com/clearfolio/viewer/artifact/FileSystemArtifactStore.java`:
- Around line 116-121: Update rollbackPartialWrite so metadataPath(docId) and
pdfPath(docId) deletion each runs in its own try/catch, adding every IOException
to writeFailure as a suppressed exception while always attempting both
deletions. Add a regression test that makes the metadata path a non-empty
directory, verifies that deletion fails, and confirms the PDF file is still
deleted.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5bba0ea4-d76d-4fe6-9773-98c479c8930b

📥 Commits

Reviewing files that changed from the base of the PR and between 55d7ae8 and 90ec7d4.

📒 Files selected for processing (2)
  • src/main/java/com/clearfolio/viewer/artifact/FileSystemArtifactStore.java
  • src/test/java/com/clearfolio/viewer/artifact/FileSystemArtifactStorePartialWriteTest.java

Comment thread src/main/java/com/clearfolio/viewer/artifact/FileSystemArtifactStore.java Outdated
@seonghobae
seonghobae enabled auto-merge (squash) August 10, 2026 22:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant