Skip to content

Bug: Windows printer failures can expose the full PowerShell EncodedCommand in support tickets #789

Closed

Description

@itsbkm

Bug description

A Windows receipt-print support report from FloCafe 3.7.6 contains an enormous error beginning with:

Command failed: powershell -NoProfile -NonInteractive -EncodedCommand ...

The remainder is the full base64-encoded PowerShell/C# raw-print helper. This was presented as the printer failure and copied into the support ticket instead of a bounded, useful diagnosis.

The current code still has the same failure path.

Code validation

In printViaUSBWindows() (main/printers/thermal.ts):

const rawStderr = String(err.stderr || '').trim();
const cleanStderr = sanitizePowerShellStderr(rawStderr);
const detail = cleanStderr || String(err.message || '').trim();

When PowerShell exits without stderr (for example, a process-level launch failure, kill, or timeout), Node's execFile error message includes the complete command line. Because the script is passed through -EncodedCommand, detail becomes a very large base64 blob. The backend returns it as the printer detail; the frontend then surfaces/copies it into the support flow.

Existing windows-print-stderr.test.ts coverage validates CLIXML cleanup only. It does not cover empty stderr plus a command-bearing err.message.

Steps to reproduce

  1. On Windows, make the powershell raw-print subprocess fail at the process level without producing stderr (a forced timeout/kill or launch failure can be used in a test).
  2. Attempt a receipt or KOT print.
  3. Inspect the returned detail, toast/support payload, or generated support ticket.

Expected behavior

The user and support ticket receive a short, classified diagnostic such as "Windows print command timed out" or "Could not start the Windows print helper." Raw command lines, encoded scripts, temporary paths, and environment-derived arguments are never returned.

Actual behavior

The complete powershell ... -EncodedCommand <base64> invocation is returned as the printer error. It can overwhelm the UI/ticket, obscures the cause, and creates an avoidable data-exposure risk if command arguments change in the future.

Environment

  • Windows x64
  • Observed on FloCafe 3.7.6
  • Receipt printing through the Windows raw spooler path
  • Current main branch remains affected

Acceptance criteria

  • Process-level PowerShell failures are mapped to bounded, user-facing messages without including the raw command or encoded helper.
  • Timeout, abort, executable-not-found, and unknown process failures receive stable classifications.
  • Detail length is capped before it reaches API responses, telemetry, or support-ticket payloads.
  • Regression tests cover empty stderr with a command-bearing err.message and prove EncodedCommand/base64 is absent.
  • Existing clean stderr and CLIXML diagnostics remain intact.

Activity

  1. khaira777 commented on Sep 21, 2026

    @khaira777
    Contributor

    working on a fix

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions