Skip to content

Bug: qfc-metrics-flush-writes-empty-session-file #646

Description

@drmoisan
  • Work Mode: minor-audit

Summary

QfcHomeController.WriteMetricsAsync invokes the injected MetricsFileWriter unconditionally, even
when the null-and-whitespace filter leaves the diagnostic-line array empty. The default writer
FileIO2.WriteTextFileAsync opens an append StreamWriter, so a QuickFiler session that produces no
diagnostic lines now creates, or touches, a zero-content session-metrics file.

The EFC sibling path already guards against this. EfcHomeController.Metrics.cs returns early:

if (dataLines.Length == 0)
{
    return;
}

QfcHomeController.Metrics.cs has no matching guard at the point where it awaits the writer.

This is a narrow regression introduced by the #442 flush fix, not a pre-existing defect. Before
that fix the QFC metrics queue was never drained, so nothing was ever written and the empty-array
case could not manifest. Making the flush work made it reachable.

The remedy is one guard in an owned file, mirroring the EFC form:

if (lines.Length == 0)
{
    return;
}

It was deliberately not applied inside feature quickfiler-home-controller-metrics-442. That
feature's plan was complete and its toolchain green at the time the finding was raised by
feature-review (finding CR-1, Minor, non-blocking), and the repository's General Code Change Policy
directs opening a new issue rather than widening the scope of work in flight.

Environment

  • OS/version: Windows 11, Outlook VSTO add-in host
  • Python version: not applicable (C# / .NET Framework 4.8)
  • Command/flags used: vstest.console.exe QuickFiler.Test\bin\Debug\QuickFiler.Test.dll
  • Data source or fixture: the session-metrics CSV in the user's MyDocuments folder

Steps to Reproduce

  1. Run a QuickFiler filing session in which GetMoveDiagnostics returns an array whose every
    element is null or whitespace - for example a session in which no item is actually moved.
  2. Let the session reach its metrics write.
  3. Inspect the session-metrics file in MyDocuments.

Expected Behavior

No write occurs and no file is created or touched, because there is no diagnostic content to record.
This matches the EFC path's behavior for the same input.

Actual Behavior

MetricsFileWriter is invoked with an empty array. The default writer opens the target for append,
so the file is created if absent and its last-write timestamp is updated if present, in both cases
recording nothing.

Logs / Screenshots

  • Attached minimal logs or snippet
  • Snippet: the unconditional call is the closing statement of WriteMetricsAsync:
    await MetricsFileWriter(filename, lines, myDocuments, CancellationToken.None);
    reached whatever the length of lines.

Impact / Severity

  • Blocker
  • High
  • Medium
  • Low

Low. The worst outcome is a spurious empty or unchanged-content file in the user's MyDocuments
folder. No data is lost, no exception is raised, and no downstream consumer exists - the
session-metrics CSV has no in-repo reader.

Source

From: docs/features/potential/2026-08-27-qfc-metrics-flush-writes-empty-session-file.md

Activity

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