Skip to content

Reader: a diagnostics channel for notify-and-continue conditions #385

Closed

Description

@Tim81

No way for a caller to learn about a notify-and-continue condition

ISO 32000-2 Annex I.2 (informative) describes what a PDF processor should do when it hits a
recoverable problem: "Upon the first error that is caused by encountering an unrecognised feature,
the PDF processor should notify the user that an error has occurred but that no further errors
will be reported. ... Processing should continue if possible." The reader follows the "continue"
half of that everywhere it can, but has no channel for the "notify" half — no ILogger, no event,
no diagnostics object a caller can inspect after the fact.

#373 is the motivating case: an indirect /Filter that fails to resolve is, per §7.3.10 and
§7.3.9, correctly treated as no /Filter at all, so the stream comes back unfiltered rather than
throwing. That reading is settled and #373 closes on it. But it means a document with this shape
hands back wrong-looking content (compressed bytes where the caller expected plaintext) with
nothing to tell them the reader took a spec-sanctioned shortcut instead of running the filter they
declared. Every other unresolvable object in the reader degrades to a visible null; this one
degrades to content that looks correct and isn't, and this issue is the general fix for that class
of problem, not just the one instance.

Also in scope, found alongside #373: PdfFilters.GetFilterList (src/VellumPdf.Reader/Filters.cs,
~:588-597) has two neighbouring drops that are not spec-mandated the way the null case is — they're
malformed input, not a null object:

  • A /Filter array whose elements are not all names silently skips the non-name ones and decodes
    with whatever's left.
  • A /Filter value that's neither a name nor an array (a number, a dictionary, whatever) yields an
    empty filter list — same "stream has no filter" outcome as the null case, but for a different and
    arguably worse reason: the document said something is wrong, not nothing.

These three shapes — spec-mandated null, malformed array element, malformed value — currently look
identical to a caller: an unfiltered stream and no exception. They deserve to be distinguishable,
which means a vocabulary for "this condition happened" beyond a single bool.

Existing precedent

PdfDocumentReader.WasReconstructed is the one thing in the reader today that reports a
recoverable condition back to the caller — a single bool, and VellumPdf.Reader is still Preview
so its shape isn't locked. A richer diagnostics surface could grow from the same idea: one member
among several, rather than a one-off.

Origin

Found in the review round of #372 (which itself grew out of #206), where the absence of a warning
channel was identified as the common root of several findings, #373 among them. Related: #228
(nothing asserts the oracles actually ran) is the same shape of problem — a check that silently
doesn't discriminate — on the test-tooling side rather than the reader side.

Activity

  1. added this to the Backlog milestone on Aug 31, 2026
  2. Tim81 commented on Aug 31, 2026

    @Tim81
    OwnerAuthor

    Found while closing #373: the ISO clause chain that settles the scalar /Filter case doesn't
    cover one of the two malformed-input drops already listed above as in scope.

    GetFilterList's array branch silently skips an element that fails to resolve:

    if (Deref(resolve, arr[i]) is PdfName fn) list.Add(fn);

    Table 5 ("Entries common to all stream dictionaries") describes /Filter as "the name, or an
    array of zero, one or several names" — nothing there sanctions a null element the way the table
    does for /DecodeParms, whose array entry is explicitly "the parameter dictionary for that
    filter, or the null object if that filter has no parameters." That asymmetry means an
    unresolvable /Filter array element isn't the same spec-mandated-null shape as the scalar case
    #373 closed on; it's the malformed-array-element drop already named above, now with the Table 5
    citation that pins it there rather than leaving it looking like a smaller instance of the settled
    scalar case.

  3. added 2 commits that reference this issue on Sep 6, 2026
    1172292
    568dec1
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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions