Skip to content

Report write failures are swallowed by table, vertical, Markdown and CycloneDX reporters #3256

Open

Description

@rajatkaliani

Summary

Report destination errors are swallowed by the table, vertical, Markdown, and CycloneDX reporters. When a writer rejects the report (for example, because its storage is full), reporter.PrintResult returns nil for those formats. JSON, HTML, SARIF, and SPDX correctly return the same error.

This can prevent the CLI from detecting an empty or incomplete output report. The reproduction below uses the real reporter API with an intentionally failing writer; no disk needs to be filled and no network or vulnerability-service access is required.

Environment

  • main at eda4d27
  • Go 1.27.3, macOS arm64

Reproduction

Save this as internal/reporter/write_failure_repro_test.go and run:

go test ./internal/reporter -run '^TestReportWriteFailure$' -count=1 -v
package reporter_test

import (
    "errors"
    "testing"

    "github.com/google/osv-scanner/v2/internal/reporter"
    "github.com/google/osv-scanner/v2/pkg/models"
)

var errDestinationFull = errors.New("output storage is full")

type failingReportWriter struct { calls int }

func (w *failingReportWriter) Write([]byte) (int, error) {
    w.calls++
    return 0, errDestinationFull
}

func TestReportWriteFailure(t *testing.T) {
    formats := []string{
        "json", "table", "vertical", "markdown",
        "cyclonedx-1-6", "html", "sarif", "spdx-2-3",
    }
    for _, format := range formats {
        t.Run(format, func(t *testing.T) {
            w := &failingReportWriter{}
            err := reporter.PrintResult(
                &models.VulnerabilityResults{}, format, w, 0, false,
            )
            t.Logf("writes=%d error=%v", w.calls, err)
            if !errors.Is(err, errDestinationFull) {
                t.Errorf("destination rejected the report, got error %v", err)
            }
        })
    }
}

Actual result

Each format attempts one write:

Format Error returned
JSON output storage is full
Table nil
Vertical nil
Markdown nil
CycloneDX 1.6 nil
HTML output storage is full
SARIF output storage is full
SPDX 2.3 output storage is full

CycloneDX also logs:

WARN Failed to parse package URL: output storage is full

The error is from writing the report, not parsing a package URL.

Expected behavior

Report write failures should propagate to the caller consistently across formats. A successfully completed scan should not conceal a failed report write.

Relevant code

Proposed contribution

I would like to contribute a focused fix and regression tests for report destination errors, preserving successful report contents and the existing behavior for unsupported package URLs. Could a maintainer confirm the preferred approach and assign this issue to me?

Activity

  1. VISHNU0906 commented on Nov 6, 2026

    @VISHNU0906

    I'd like to take this. I can add write-error propagation for the table, vertical, Markdown, and CycloneDX reporters to match JSON/HTML/SARIF/SPDX, with a regression test using a failing writer.

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