Skip to main content

File Source Node

The filesource node reads one local file, decodes its whole content with the configured format, and emits the resulting records. It is a batch source: it reads the file once and then ends. Internal ZephFlow engine command for local and CLI runs. Not offered in Fleak Data Workflow and not supported in Fleak Data Workflow workflows; do not add it to a workflow.

Internal engine command

Internal ZephFlow engine command for local and CLI runs. Not offered in Fleak Data Workflow and not supported in Fleak Data Workflow workflows; do not add it to a workflow.

Key Features​

  • Single file: Reads exactly one regular file from the local filesystem
  • Whole-file parsing: The entire file is decoded as one payload with the configured decoding
  • Batch source: Reads the file once, emits its records, and ends

Config Object​

The full config object for the file source node (FileSourceDto.Config):

FieldTypeRequiredDefaultDescription
filePathStringYes—Path of the file to read. Must exist and be a regular file; directories and glob patterns are rejected
decodingObjectYes—Compression and format of the file. See Decoding

The path is checked when the DAG is compiled: a missing file fails with file doesn't exist: <path>, and a directory with file is not a regular file: <path>.

Decoding​

decoding sets how each file is read: its compression and its format. decoding is required, and a config without it, or with a bad one, fails validation.

decoding:
compression: gzip # optional
format:
type: json
mode: lines
  • compression is one codec or a list applied in order: gzip, zstd, bzip2, xz, lz4 (frame format), snappy (framing format), deflate (zlib), or auto, which gunzips a file that starts with the gzip magic bytes and passes any other through. auto cannot be combined with another codec.
  • format.type is one of json, text, csv, xml, yaml, avro, protobuf, otlp, parquet, auto. parquet cannot be combined with compression, and kv is rejected. See Formats for each format's parameters.

With no compression, nothing is decompressed, and a csv or text file that starts with a compression signature fails as MALFORMED instead of giving garbage records.

How the File Is Read​

Paths and Docker​

A relative filePath resolves against the working directory of the ZephFlow process. In the fleak/zephflow-clistarter Docker image the working directory is /app, so either mount the file into /app and use a relative path, or mount it elsewhere and use an absolute path. A file on the host is not visible to the container unless it is mounted.

One Payload per File​

The whole file is read into memory and decoded as a single payload, with no limit on record or document size, so files are expected to be small. If any part of it fails to decode, for example one malformed line in a JSON Lines file, the whole file fails and none of its records are emitted. The failure is logged at ERROR level with the file content, as text when it is readable and otherwise in base64. When jobContext.dlqConfig is set, the file content is written to the DLQ with the node's ID in nodeId; otherwise it is dropped. If writing the entry fails, the failure is logged and the source goes on; that entry is lost.

The DLQ error text has a first line that names the problem, an Action: line, then the stack trace and, when known, the record index and byte range:

MALFORMED json file: JsonParseException
Action: check that the file is json as the source's decoding says, and that its compression is set when the file is compressed; fix the file and run the job again
<stack trace>
recordIndex 2, bytes 10-25 (and 1 more problem)

The other first lines are CORRUPT_COMPRESSION <format> file: <exception>, OVERSIZED <format> file: <limit> and READ_FAILURE <format> file: <exception>.

An empty file gives no records and no DLQ entry, with these exceptions: Protobuf single gives one record of default values, and Avro datum and Parquet fail, unless the Avro schema fits in zero bytes. These also fail the file:

  • A JSON Lines line holding an array, or with invalid UTF-8.
  • A CSV row with more columns than the header, or duplicate header names. An empty header name becomes _c<i>.
  • XML with a DOCTYPE, a second root element, or text after the root.

After the single read, the source ends and the pipeline finishes once the records have been processed.

To read many files, files in object storage, or files that should be resumed after a restart, use fssource (the file backend reads from the local filesystem).

Job Context​

The DAG definition must contain a jobContext block, which may be empty (jobContext: {}). Without it, the CLI starter fails with a NullPointerException before the DAG runs.

Examples​

DAG Definition​

Create events.jsonl:

{"user": "alice", "status": 200}
{"user": "bob", "status": 500}

Save as filesource_example.yml:

jobContext: {}

dag:
- id: "file_source"
commandName: "filesource"
config:
filePath: "events.jsonl"
decoding:
format:
type: json
mode: lines
outputs:
- "errors_only"

- id: "errors_only"
commandName: "filter"
config:
expression: $.status >= 500
outputs:
- "stdout_sink"

- id: "stdout_sink"
commandName: "stdout"
config:
encoding:
format:
type: json
mode: object
outputs: []

Run it with the CLI starter, mounting both files into /app:

docker run \
-v $(pwd)/filesource_example.yml:/app/filesource_example.yml \
-v $(pwd)/events.jsonl:/app/events.jsonl \
fleak/zephflow-clistarter:latest -f /app/filesource_example.yml

Between the log lines, the output contains:

{"user":"bob","status":500}
  • fssource: Read files from S3, GCS, Azure Blob Storage, SFTP, or the local filesystem (file backend), with checkpointing
  • stdin: Read records from standard input
  • stdout: Print records to standard output