Skip to content

Access log format.text without format.type is silently dropped for File and ALS sinks #9719

Closed

Description

@UgaTheDev

What happened

ProxyAccessLogFormat.Type is optional. The CEL rule on the type only requires that
something is set when the type is omitted:

// api/v1alpha1/envoyproxy_accesslogging_types.go
// +kubebuilder:validation:XValidation:rule="!has(self.type) ? (has(self.text) || has(self.json)) : true",message="If AccessLogFormat type is unset, at least one of text or json must be set."

So format: {text: "..."} with no type is accepted by the API server for any sink type.
The OpenTelemetry sink honors it. File and ALS do not: the text is dropped and the built-in
default JSON fields are emitted instead. No error, no status condition.

Config that gets dropped

apiVersion: gateway.envoyproxy.io/v1alpha1
kind: EnvoyProxy
metadata:
  name: custom-proxy-config
  namespace: envoy-gateway-system
spec:
  telemetry:
    accessLog:
      settings:
        - format:
            text: |
              custom %START_TIME% %REQ(:METHOD)% %RESPONSE_CODE%
          sinks:
            - type: File
              file:
                path: /dev/stdout

Expected: the file sink logs with that format string. Actual: the proxy logs the default
JSON access log fields.

Where

internal/gatewayapi/listener.go

File sink, line 899:

if format.Type != nil && *format.Type == egv1a1.ProxyAccessLogFormatTypeText {

ALS sink, line 963: same test.

With format.Type == nil both fall to the else branch, which builds an ir.JSONAccessLog
from format.JSON. format.JSON is nil here, and ir.MapToSlice(nil) returns nil, so the
IR carries an empty field list. internal/xds/translator/accesslog.go lines 159-163 then
substitutes the defaults:

if json.JSON != nil {
    jsonLogFields = json.JSON
} else {
    jsonLogFields = ir.MapToSlice(EnvoyJSONLogFields)
}

The OpenTelemetry sink at line 1015 uses a different test and does handle the nil type:

if format.Type == nil || *format.Type == egv1a1.ProxyAccessLogFormatTypeText {
    al.Text = format.Text
}

There is a third path with the same outcome: when len(accessLog.Sinks) == 0, lines 882-890
build a JSONAccessLog on /dev/stdout unconditionally. There is no text branch at all, so
a type-less text format is dropped there too, and so is format: {type: Text, text: "..."}
with no sinks.

Confirmed by

Calling processAccessLog directly with the EnvoyProxy above (type-less text format, one
File sink) returns an ir.AccessLog with 0 entries in Text and 1 in JSON, whose JSON
field list is empty. That is the input to the xds default substitution above.

Question

The type-less format looks like it was added for the OpenTelemetry sink, where text (body)
and attributes are both meaningful. Two directions:

  1. Make the File and ALS paths (and the no-sink stdout path) honor a type-less text format,
    matching the OTel behavior.
  2. Add a CEL rule rejecting a type-less format when a non-OTel sink is configured, so the
    config is refused instead of silently ignored.

Which do you prefer? Happy to send a PR either way.

Environment

main at f1d26db.

Activity

  1. added a commit that references this issue on Aug 25, 2026
    61f6772
  2. added 3 commits that reference this issue on Aug 28, 2026
    df63a5c
    c30c739
    8912159
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

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions