vortegatorres opened a new issue, #11424:
URL: https://github.com/apache/apisix/issues/11424

   ### Current Behavior
   
   After executing the `serverless-pre-function` plugin with a Lua script that 
modifies the response, the `upstream_status` value is empty. This leads to 
issues such as an incorrect http_status attribute in the span when the 
OpenTelemetry plugin is executed, as [it relies on the upstream_status 
value](https://github.com/apache/apisix/blob/da5039da4122e66ffeba44f84f87ca7a731b5455/apisix/plugins/opentelemetry.lua#L393).
   
   
   
   ### Expected Behavior
   
   Ensure `upstream_status` retains a correct value after executing a Lua 
script that calls the `core.response.exit()` function.
   
   
   
   ### Error Logs
   
   ````
   {"ts": "2024-07-23T08:07:17+00:00", "service": "apisix", "resp_body_size": 
"162", "host": "-------", "address": "-------", "request_length": "446", 
"method": "GET", "uri": "-----", "status": "401", "user_agent": "------", 
"resp_time": "0.002", "upstream_addr": "", "upstream_status": "", 
"traceparent": 
"00-dc0718f09c93b3c1c4e4e42f5de40e44-42eaf107d787a636-01","trace_id": 
"dc0718f09c93b3c1c4e4e42f5de40e44","span_id": "42eaf107d787a636"}
   ````
   
   ### Steps to Reproduce
   
   1. Start APISIX.
   2. Configure logs to display `upstream_status` by including it in the 
`nginx_config.http.access_log_format.`
   3. Add a `serverless-pre-function` plugin that modifies the response status 
code:
   ```
   curl http://127.0.0.1:9180/apisix/admin/routes/1 -H 'X-API-KEY: 
edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
   {
       "uri": "/your-endpoint",
       "plugins": {
           "serverless-pre-function": {
               "phase": "rewrite",
               "functions": ["return function() local core = 
require(\"apisix.core\"); core.response.exit(401); end"]
           }
       }
   }'
   ```
   4. Check the logs and verify that `upstream_status` is empty.
   
   ### Environment
   
   - APISIX version (run `apisix version`): 3.7.0
   - Operating system (run `uname -a`): x86_64 GNU/Linux
   - OpenResty / Nginx version (run `openresty -V` or `nginx -V`): nginx 
version: openresty/1.21.4.2
   - etcd version, if relevant (run `curl 
http://127.0.0.1:9090/v1/server_info`): etcd-8.7.7
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to