Skip to main content

Stdin Source Node

The stdin node reads lines from the standard input of the ZephFlow process, decodes each line with the configured format, and emits the resulting records. It reads until end of input or the first empty line, 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​

  • Line-by-line parsing: Each input line is decoded on its own with the configured decoding
  • One batch per run: All lines are read first and emitted together; the source then ends
  • Dead-lettering: A line that fails to decode goes to the DLQ when one is configured

Config Object​

The full config object for the stdin node (StdInSourceDto.Config):

FieldTypeRequiredDefaultDescription
decodingObjectYes—Format of each input line, as format.type and its parameters. See Formats. Multiline framing is rejected
decoding:
format:
type: json
mode: object

decoding is required, and a config without it, or with a bad one, fails validation.

How Input Is Read​

End of Input​

When the node starts it prints use an empty line to quit to stdout. It then reads lines until standard input reaches end of file (for example Ctrl+D, or the end of a piped file) or until the first empty or whitespace-only line. Lines after that empty line are ignored. All lines read are then emitted as one batch, and the source ends. Nothing is emitted while lines are still being typed.

When running in Docker, pass -i so that the container's standard input stays open.

Per-Line Decoding​

Each line is decoded separately. As a consequence:

  • A JSON array or object must be on a single line. In a pretty-printed array spread over several lines, every line fails to decode and no records are emitted.
  • A csv format with a header yields no records, because each line is read as its own CSV document and a single line is only a header. Set header: false, optionally with columns, to get a record per line.
  • The text format turns each line into a record with the line in __raw__.
  • Multiline framing is rejected at validation, because a line never continues another.
  • Each line has been read as text and re-encoded before it is decoded, so binary formats and compression cannot be read from stdin.

Decode Failures​

A line that fails to decode is logged at ERROR level with its content, as text when it is readable and otherwise in base64. When jobContext.dlqConfig is set, the line is written to the DLQ with the stdin node's ID in nodeId; otherwise it is dropped. The other lines are not affected. 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 message: JsonParseException
Action: check that the message is json as the source's decoding says, and that its compression is set when the message is compressed, or fix the producer that wrote it; the DLQ value is the message as received, so it can be sent again
<stack trace>

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

An input line is never empty, since the first empty line ends the input. These lines fail instead of decoding:

  • A JSON Lines line holding an array.
  • A CSV row with more columns than the header, or duplicate header names.
  • XML with a DOCTYPE, a second root element, or text after the root.

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​

Save as stdin_example.yml:

jobContext: {}

dag:
- id: "stdin_source"
commandName: "stdin"
config:
decoding:
format:
type: json
mode: object
outputs:
- "stdout_sink"

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

Run it with the CLI starter and pipe two lines to it:

printf '{"user": "alice", "status": 200}\n{"user": "bob", "status": 500}\n' | docker run -i \
-v $(pwd)/stdin_example.yml:/app/stdin_example.yml \
fleak/zephflow-clistarter:latest -f /app/stdin_example.yml

Between the log lines, the output contains:

use an empty line to quit
{"user":"alice","status":200}
{"user":"bob","status":500}
  • stdout: Print records to standard output
  • filesource: Read a single local file
  • fssource: Read files from S3, GCS, Azure Blob Storage, SFTP, or the local filesystem