Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set the response_code_details in the access log when failures occur in the transformation filter. #377

Open
pszeto opened this issue Dec 11, 2024 · 0 comments

Comments

@pszeto
Copy link

pszeto commented Dec 11, 2024

Sometimes the transformation filter will fail parsing the body because it's not a JSON...when it fails the response_code_details is never changed from the upstream.

For example. When calling httpbin.org/xlm . It will return a 200 response code and a "response_code_details":"via_upstream" however when we add the Transformation Filter and it tries to parse the the body it fails:

2024-12-11T15:48:35.520916Z	debug	envoy filter external/envoy_gloo/source/extensions/filters/http/transformation/transformation_filter.cc:259	[Tags: "ConnectionId":"1144","StreamId":"651067811395905973"] body before transformation: <?xml version='1.0' encoding='us-ascii'?>

<!--  A SAMPLE set of slides  -->

<slideshow
    title="Sample Slide Show"
    date="Date of publication"
    author="Yours Truly"
    >

    <!-- TITLE SLIDE -->
    <slide type="all">
      <title>Wake up to WonderWidgets!</title>
    </slide>

    <!-- OVERVIEW -->
    <slide type="all">
        <title>Overview</title>
        <item>Why <em>WonderWidgets</em> are great</item>
        <item/>
        <item>Who <em>buys</em> WonderWidgets</item>
    </slide>

</slideshow>	thread=21
2024-12-11T15:48:35.521006Z	debug	envoy filter external/envoy_gloo/source/extensions/filters/http/transformation/transformation_filter.cc:276	[Tags: "ConnectionId":"1144","StreamId":"651067811395905973"] failure transforming [json.exception.parse_error.101] parse error at line 1, column 1: syntax error while parsing value - invalid literal; last read: '<'	thread=21
2024-12-11T15:48:35.521035Z	trace	envoy http external/envoy/source/common/http/filter_manager.cc:1428	[Tags: "ConnectionId":"1144","StreamId":"651067811395905973"] encode data called: filter=io.solo.transformation status=0thread=21
2024-12-11T15:48:35.521051Z	trace	envoy http external/envoy/source/common/http/filter_manager.cc:68	[Tags: "ConnectionId":"1144","StreamId":"651067811395905973"] continuing filter chain: filter=0x265eff033c20	thread=21
2024-12-11T15:48:35.521086Z	trace	envoy http external/envoy/source/common/http/filter_manager.cc:905	[Tags: "ConnectionId":"1144","StreamId":"651067811395905973"] commonEncodePrefix end_stream: false, isHalfCloseEnabled: false	thread=21
2024-12-11T15:48:35.521103Z	trace	envoy http external/envoy/source/common/http/filter_manager.cc:1243	[Tags: "ConnectionId":"1144","StreamId":"651067811395905973"] encode headers called: filter=istio.stats status=0	thread=21
2024-12-11T15:48:35.521118Z	trace	envoy http external/envoy/source/common/http/filter_manager.cc:1243	[Tags: "ConnectionId":"1144","StreamId":"651067811395905973"] encode headers called: filter=envoy.filters.http.cors status=0	thread=21
2024-12-11T15:48:35.521134Z	trace	envoy http external/envoy/source/common/http/filter_manager.cc:1243	[Tags: "ConnectionId":"1144","StreamId":"651067811395905973"] encode headers called: filter=envoy.filters.http.fault status=0	thread=21
2024-12-11T15:48:35.521168Z	trace	envoy http external/envoy/source/common/http/filter_manager.cc:1243	[Tags: "ConnectionId":"1144","StreamId":"651067811395905973"] encode headers called: filter=envoy.filters.http.grpc_stats status=0	thread=21
2024-12-11T15:48:35.521201Z	trace	envoy http external/envoy/source/common/http/filter_manager.cc:1243	[Tags: "ConnectionId":"1144","StreamId":"651067811395905973"] encode headers called: filter=istio.metadata_exchange status=0	thread=21
2024-12-11T15:48:35.521265Z	debug	envoy http external/envoy/source/common/http/conn_manager_impl.cc:1825	[Tags: "ConnectionId":"1144","StreamId":"651067811395905973"] encoding headers via codec (end_stream=false):
':status', '400'
'server', 'istio-envoy'
'date', 'Wed, 11 Dec 2024 15:48:35 GMT'
'content-length', '145'
'access-control-allow-origin', '*'
'access-control-allow-credentials', 'true'
'x-envoy-upstream-service-time', '3'
	thread=21

The access log has "response_code_details": "via_upstream", and "response_code": 400

{
  "response_code_details": "via_upstream",
  "downstream_local_address": "10.16.2.12:8443",
  "route_name": "insecure-echo-echo-rt-echo-configs-pszeto-mgmt-gke",
  "authority": "35.237.146.57",
  "x_forwarded_for": "136.56.75.24",
  "path": "/echo",
  "downstreamTLS": "TLSv1.3",
  "response_flags": "-",
  "x_request_id": "2670332b-2c7d-42c4-80f6-7163b6455b35",
  "upstream_cluster": "outbound|8000||in-mesh.httpbin.svc.cluster.local;",
  "requested_server_name": null,
  "upstream_tls_session_id": null,
  "bytes_received": 0,
  "client_ip": null,
  "duration": 5,
  "peerUriSan": null,
  "upstream_service_time": null,
  "upstreamTLS": "TLSv1.3",
  "user_agent": "curl/8.4.0",
  "downstream_remote_address": "136.56.75.24:50504",
  "downstream_tls_session_id": null,
  "start_time": "2024-12-11T15:48:35.516Z",
  "method": "GET",
  "upstream_host": "10.16.0.16:80",
  "upstream_transport_failure_reason": null,
  "response_code": 400,
  "localUriSan": null,
  "bytes_sent": 145,
  "upstream_local_address": "10.16.2.12:52072",
  "protocol": "HTTP/2"
}

The response_code_details should be change to something instead of via_upstream which might cause inaccurate assumption that the upstream returned the 400. Especially since the error line:

2024-12-11T15:48:35.521006Z	debug	envoy filter external/envoy_gloo/source/extensions/filters/http/transformation/transformation_filter.cc:276	[Tags: "ConnectionId":"1144","StreamId":"651067811395905973"] failure transforming [json.exception.parse_error.101] parse error at line 1, column 1: syntax error while parsing value - invalid literal; last read: '<'	thread=21

is a debug line and when debug isn't enabled on the envoy...we never see any error condition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant