--- title: "ADR 0005: Bounding the size of emitted events, and copying the emitter" --- * Status: accepted * Code: [`pkg/events/emit.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/events/emit.go) ## Context PAC emits Kubernetes Events to report pipeline results back to the user in the provider UI. Two constraints shape how `EventEmitter` builds them. The events API caps a note at 1 KB. PAC messages are often YAML parse errors, which embed whole files, so a single bad `.tekton` directory can generate a message far over the limit and be rejected by the API server, or bloat etcd if it were accepted. The emitter is created once and shared. `SetLogger` mutates it, and several reconcile paths want a logger carrying different fields without changing the shared instance. ## Decision * `maxEventMessageLen` is 1024 bytes, matching the API limit, and `truncateEventMessage` cuts to that budget with a `... (truncated)` suffix, backing up over continuation bytes so a multi-byte [UTF-8](https://issues.redhat.com/browse/UTF-8) character is never split. * Truncation applies to the Event only. The log line keeps the full message, because the log is where someone debugs the truncation. * `WithLogger` returns a copy with the logger replaced; the receiver is untouched. `SetLogger` remains for callers that own their emitter. ## Consequences * An event message can be a prefix of the real message, with no indication of what was dropped beyond the suffix. * Copying is shallow: the copy shares the client and any other pointer fields. That is safe for loggers, and would not be safe if the emitter ever grew mutable state. * A message over 1 KB costs one extra allocation on the emit path, which is irrelevant next to the API call.