Skip to content

F99 text record content is empty in libfec output #15

Description

@asg017

Note

Much of this ticket was composed with Claude

FEC filings can contain [BEGINTEXT]/[ENDTEXT] blocks for miscellaneous text records (F99 form type). FastFEC captures this text content and includes it in the text column of F99.csv. libfec's fastfec subcommand outputs an empty text field.

The parser (Filing::next_row() in lib.rs:344-382) does read and accumulate the text content into a contents variable, but this content is discarded - the method returns the record that follows [ENDTEXT] without attaching the text.

Affected Filing

Filing ID: 1938291 (159 bytes, DIONE SIMS FOR CONGRESS F99 filing)
Also: 1944545 (168 bytes), 1943137 (186 bytes)

Reproduction

libfec fastfec ~/.cache/libfec/cache/1938291.fec /tmp/out_libfec
fastfec --no-stdin ~/.cache/libfec/cache/1938291.fec /tmp/out_fastfec

Observe the Difference

# Compare the F99.csv files:
diff /tmp/out_libfec/1938291/F99.csv /tmp/out_fastfec/1938291/F99.csv
# 2c2,3
# < F99,C00930974,...,20260130,MST,,
# ---
# > F99,C00930974,...,2026-01-30,MST,,"
# > "

# libfec text field is empty:
awk -F, '{print NR": text="$NF}' /tmp/out_libfec/1938291/F99.csv
# 1: text=text
# 2: text=

# FastFEC text field has content (newline in this case):
awk -F, '{print NR": text="$NF}' /tmp/out_fastfec/1938291/F99.csv
# 1: text=text
# 2: text="
# 3: "

Root Cause

In fec-parser/src/lib.rs:344-382, the [BEGINTEXT] handler accumulates text into contents:

if row_type == "[BEGINTEXT]" {
    let mut contents = String::new();
    loop {
        // ... accumulates text lines into `contents` ...
        Some(b"[ENDTEXT]") => match self.records_iter.next() {
            // Returns the NEXT record after [ENDTEXT], discarding `contents`
            return Some(Ok(FilingRow { row_type, record, original_size }));
        }
    }
}

The contents string is built up but never passed to the returned FilingRow.

Suggested Fix

Add the text content to FilingRow (perhaps as an Option<String> field), and in fastfec.rs, append it to the record before writing when present.

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions