Skip to content

Bug: sort-email-attachment-test-creates-directory-at-repository-root #945

Closed

Description

@drmoisan
  • Work Mode: minor-audit

Summary

The SortEmail_Tests test of TrySaveAttachmentAsync (UtilitiesCS.Test/EmailIntelligence/SortEmail_Tests.cs lines ~237-249) passes a path under the real repository root. It reaches Directory.CreateDirectory in UtilitiesCS/EmailIntelligence/EmailParsingSorting/SortEmail.cs (line ~896), so the unit test creates a directory in the working tree. The repository policy prohibits this, and it is the same defect class as #931 and #940.

Environment

  • OS/version: Windows 11 / windows-latest
  • Python version: n/a (C# / MSTest)
  • Command/flags used: standard MSTest coverage route
  • Data source or fixture: GetRepositoryRoot() helper in SortEmail_Tests.cs (lines ~393-415)

Steps to Reproduce

  1. Run the TrySaveAttachmentAsync test in SortEmail_Tests.
  2. Inspect the repository root for a newly created directory.

Expected Behavior

The test exercises the save path without touching the real file system, through a seam or a mock, and creates no directory or file.

Actual Behavior

Directory.CreateDirectory runs against a path derived from the repository root.

Logs / Screenshots

Impact / Severity

  • Blocker
  • High
  • Medium
  • Low

Source

From: docs/features/potential/2026-09-30-sort-email-attachment-test-creates-directory-at-repository-root.md

Activity

  1. drmoisan commented on Sep 30, 2026

    @drmoisan
    OwnerAuthor

    Restoring sections dropped by the promotion tooling.

    Suspected Cause / Notes

    TrySaveAttachmentAsync (UtilitiesCS/EmailIntelligence/EmailParsingSorting/SortEmail.cs line ~889) is marked [ExcludeFromCodeCoverage] (line ~888) and has no injectable file-system seam, so the test at UtilitiesCS.Test/EmailIntelligence/SortEmail_Tests.cs lines ~237-249 drives the real Directory.CreateDirectory (line ~896) against a path derived from the repository root. #940 classifies this site but deliberately does not modify it.

    Source: #940 research, section 5 and open question 10.

    Proposed Fix / Validation Ideas

    • Introduce an injectable file-system abstraction for the directory-creation step, reusing the existing IFileSystem-style seams in UtilitiesCS, and mock it in the test.
    • Assert that no real directory is created, using a strict mock with VerifyNoOtherCalls.
    • Negative control: the rewritten test fails if the production code bypasses the seam.
  2. drmoisan commented on Oct 1, 2026

    @drmoisan
    OwnerAuthor

    Delivered by PR 957 (merge commit 9b3eea5), parallel run bugs-2026-09-28. All 8 acceptance criteria in issue.md are checked off; all seven checks green on head 812c7cd (run 36849045538) before merge. Follow-ups are filed separately by the run coordinator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions