You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "FeiYing9 (via GitHub)" <gi...@apache.org> on 2025/04/22 09:09:50 UTC

[I] bug: apisix report error log "attempt to index field 'body' (a nil value)" [apisix]

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

   ### Current Behavior
   
   I have deploy apisix-ingress-controller according to this [chart](https://github.com/apache/apisix-helm-chart/tree/master/charts/apisix-ingress-controller)
   
   Ofcourse i enabled etcdserver in ingress-controller according to this doc: 
    https://apisix.apache.org/zh/docs/ingress-controller/composite/
   
   And, apisix seems work well, i can open a website with apisixroute, It's just that the apisix log always reports the error periodically
   
   ### Expected Behavior
   
   apisix report no error logs
   
   ### Error Logs
   
   ```shell
   2025/04/22 09:00:53 [error] 178#178: *688772 [lua] timers.lua:54: failed to wait threads, context: ngx.timer
   2025/04/22 09:01:23 [error] 178#178: *695377 lua user thread aborted: runtime error: /usr/local/apisix/apisix/core/etcd.lua:353: attempt to index field 'body' (a nil value)
   stack traceback:
   coroutine 0:
   	/usr/local/apisix/apisix/core/etcd.lua: in function 'set'
   	/usr/local/apisix/apisix/plugins/server-info.lua:128: in function 'set'
   	/usr/local/apisix/apisix/plugins/server-info.lua:192: in function 'report'
   	/usr/local/apisix/apisix/plugins/server-info.lua:292: in function </usr/local/apisix/apisix/plugins/server-info.lua:287>
   coroutine 1:
   	[C]: in function 'thread_wait'
   	/usr/local/apisix/apisix/timers.lua:52: in function </usr/local/apisix/apisix/timers.lua:32>
   	[C]: in function 'pcall'
   	/usr/local/apisix/apisix/core/timer.lua:40: in function </usr/local/apisix/apisix/core/timer.lua:36>
   	[C]: in function 'pcall'
   	/usr/local/apisix/apisix/core/timer.lua:63: in function </usr/local/apisix/apisix/core/timer.lua:56>, context: ngx.timer
   ```
   
   ### Steps to Reproduce
   
   1. get the helm chart from https://github.com/apache/apisix-helm-chart/tree/master/charts/apisix-ingress-controller
   2. modify the image about `apache/apisix:3.12.0-debian`  and `apache/apisix-ingress-controller:1.8.0`
   3. modify the config see below
   4. install apisix with helm
   
   apisix-configmap:
   ```yaml
   apiVersion: v1
   data:
     config.yaml: |-
       # log options
       log_level: "info"
       log_output: "stderr"
       cert_file: "/etc/webhook/certs/cert.pem"
       key_file: "/etc/webhook/certs/key.pem"
       http_listen: ":8080"
       https_listen: ":8443"
       ingress_publish_service: infra/apisix-gateway    # this is the right service
       enable_profiling: true
       apisix_resource_sync_interval: 1h
       plugin_metadata_cm: ""
       kubernetes:
         kubeconfig: ""
         resync_interval: "6h"
         namespace_selector:
         - ""
         election_id: "ingress-apisix-leader-composite"
         ingress_class: "apisix-composite"
         ingress_version: "networking/v1"
         watch_endpointslices: false
         apisix_route_version: "apisix.apache.org/v2"
         enable_gateway_api: false
         apisix_version: "apisix.apache.org/v2"
       apisix:
         admin_api_version: "v3"
         default_cluster_base_url: http://127.0.0.1:9180/apisix/admin
         default_cluster_admin_key: "edd1c9f034335f136f87ad84b625c8f1"
         default_cluster_name: "default"
   
       etcdserver:
         enabled: true
   kind: ConfigMap
   metadata:
     name: apisix-configmap
   ```
   
   
   apisix-gw-configmap:
   ```yaml
   apiVersion: v1
   data:
     config.yaml: |
       deployment:
         role: traditional
         role_traditional:
           config_provider: etcd
         admin:
           allow_admin:
             - 127.0.0.0/24
             - 0.0.0.0/0
           admin_listen:
             ip: 0.0.0.0
             port: 9180
           # Default token when use API to call for Admin API.
           # *NOTE*: Highly recommended to modify this value to protect APISIX's Admin API.
           # Disabling this configuration item means that the Admin API does not
           # require any authentication.
           admin_key:
             # admin: can everything for configuration data
             - name: "admin"
               key: edd1c9f034335f136f87ad84b625c8f1
               role: admin
             # viewer: only can view configuration data
             - name: "viewer"
               key: 4054f7cf07e344346cd3f287985e76a2
               role: viewer
         etcd:
           host:
             - "http://127.0.0.1:12379"
           prefix: "/apisix"
           timeout: 60
   
       apisix:
         enable_control: true
         enable_reuseport: true
         enable_heartbeat: true
         enable_admin: true
         enable_admin_cors: true
         enable_debug: false
         enable_dev_mode: false                       # Sets nginx worker_processes to 1 if set to true
         enable_ipv6: true # Enable nginx IPv6 resolver
         enable_http2: true
         enable_server_tokens: true # Whether the APISIX version number should be shown in Server header
   
         proxy_cache: # Proxy Caching configuration
           cache_ttl: 10s                     # The default caching time if the upstream does not specify the cache time
           zones: # The parameters of a cache
             - name: disk_cache_one             # The name of the cache, administrator can be specify
               # which cache to use by name in the admin api
               memory_size: 50m                 # The size of shared memory, it's used to store the cache index
               disk_size: 1G                    # The size of disk, it's used to store the cache data
               disk_path: "/tmp/disk_cache_one" # The path to store the cache data
               cache_levels: "1:2"              # The hierarchy levels of a cache
   
         router:
           http: radixtree_host_uri  # radixtree_uri: match route by uri(base on radixtree)
           # radixtree_host_uri: match route by host + uri(base on radixtree)
           # radixtree_uri_with_parameter: match route by uri with parameters
           ssl: 'radixtree_sni'        # radixtree_sni: match route by SNI(base on radixtree)
   
         proxy_mode: http
         stream_proxy:
           only: false
           tcp:
             - 9100
             - addr: 9110
               tls: true
           udp:
             - 9200
         dns_resolver_valid: 30
         resolver_timeout: 5
   
         ssl:
           enable: true
           listen:
             - port: 9443
           ssl_protocols: "TLSv1.2 TLSv1.3"
           ssl_ciphers: "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA256:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA"
   
       nginx_config:
         large_client_header_buffers: 40
         http_server_location_configuration_snippet: |
           proxy_buffering off;
         error_log: "stderr"
         error_log_level: "warn"    # warn,error
         worker_processes: "auto"
         enable_cpu_affinity: true
         worker_rlimit_nofile: 20480  # the number of files a worker process can open, should be larger than worker_connections
         event:
           worker_connections: 10620
         http:
           enable_access_log: true
           access_log: "/dev/stdout"
           access_log_format: '$remote_addr - $remote_user [$time_local] $http_host \"$request\" $status $body_bytes_sent $request_time \"$http_referer\" \"$http_user_agent\" $upstream_addr $upstream_status $upstream_response_time \"$upstream_scheme://$upstream_host$upstream_uri\"'
           access_log_format_escape: default
           keepalive_timeout: "60s"
           client_header_timeout: 60s     # timeout for reading client request header, then 408 (Request Time-out) error is returned to the client
           client_body_timeout: 60s       # timeout for reading client request body, then 408 (Request Time-out) error is returned to the client
           send_timeout: "600s"              # timeout for transmitting a response to the client.then the connection is closed
           underscores_in_headers: "on"   # default enables the use of underscores in client request header fields
           real_ip_header: "X-Real-IP"    # http://nginx.org/en/docs/http/ngx_http_realip_module.html#real_ip_header
           real_ip_from: # http://nginx.org/en/docs/http/ngx_http_realip_module.html#set_real_ip_from
             - 127.0.0.1
             - 'unix:'
           lua_shared_dict: # Nginx Lua shared memory zone. Size units are m or k.
             prometheus-metrics: 50m # In production, less than 50m is recommended
           http_configuration_snippet: |
             large_client_header_buffers 40 32k;
   
       plugins:                          # plugin list (sorted by priority)
         - real-ip
         - ai
         - client-control
         - proxy-control
         - request-id
         - zipkin
         - opentelemetry
         - ext-plugin-pre-req
         - fault-injection
         - mocking
         - serverless-pre-function
         - cors
         - ip-restriction
         - ua-restriction
         - referer-restriction
         - csrf
         - uri-blocker
         - request-validation
         - chaitin-waf
         - multi-auth
         - openid-connect
         - cas-auth
         - authz-casbin
         - authz-casdoor
         - wolf-rbac
         - ldap-auth
         - hmac-auth
         - basic-auth
         - jwt-auth
         - jwe-decrypt
         - key-auth
         - consumer-restriction
         - forward-auth
         - opa
         - authz-keycloak
         - proxy-cache
         - body-transformer
         - proxy-mirror
         - proxy-rewrite
         - workflow
         - api-breaker
         - limit-conn
         - limit-count
         - limit-req
         - gzip
         - server-info
         - traffic-split
         - redirect
         - response-rewrite
         - degraphql
         - kafka-proxy
         - grpc-transcode
         - grpc-web
         - public-api
         - prometheus
         - datadog
         - loki-logger
         - elasticsearch-logger
         - echo
         - loggly
         - http-logger
         - splunk-hec-logging
         - skywalking-logger
         - google-cloud-logging
         - sls-logger
         - tcp-logger
         - kafka-logger
         - rocketmq-logger
         - syslog
         - udp-logger
         - file-logger
         - clickhouse-logger
         - tencent-cloud-cls
         - inspect
         - example-plugin
         - aws-lambda
         - azure-functions
         - openwhisk
         - openfunction
         - serverless-post-function
         - ext-plugin-post-req
         - ext-plugin-post-resp
   
       plugin_attr:
         opentelemetry:
           set_ngx_var: true
         prometheus:
           enable_export_server: true
           export_addr:
             ip: 0.0.0.0
             port: 9091
             export_uri: /apisix/prometheus/metrics
             metric_prefix: apisix_
             metrics:
               http_latency:
                 extra_labels:
                   - host: $host
                   - upstream_addr: $upstream_addr
                   - upstream_status: $upstream_status
                   - uri: $uri
                   - method: $request_method
               http_status:
                 extra_labels:
                   - host: $host
                   - upstream_addr: $upstream_addr
                   - upstream_status: $upstream_status
                   - uri: $uri
                   - method: $request_method
   kind: ConfigMap
   metadata:
     name: apisix-gw-configmap
   ```
   
   ### Environment
   
   - APISIX version (run `apisix version`):  `apache/apisix:3.12.0-debian`  and `apache/apisix-ingress-controller:1.8.0`
   - Operating system (run `uname -a`): 
   ```shell
   kubectl  version
   WARNING: This version information is deprecated and will be replaced with the output from kubectl version --short.  Use --output=yaml|json to get the full version.
   Client Version: version.Info{Major:"1", Minor:"27", GitVersion:"v1.27.5", GitCommit:"93e0d7146fb9c3e9f68aa41b2b4265b2fcdb0a4c", GitTreeState:"clean", BuildDate:"2023-08-24T00:48:26Z", GoVersion:"go1.20.7", Compiler:"gc", Platform:"linux/amd64"}
   Kustomize Version: v5.0.1
   Server Version: version.Info{Major:"1", Minor:"27", GitVersion:"v1.27.5", GitCommit:"93e0d7146fb9c3e9f68aa41b2b4265b2fcdb0a4c", GitTreeState:"clean", BuildDate:"2023-08-24T00:42:11Z", GoVersion:"go1.20.7", Compiler:"gc", Platform:"linux/amd64"}
   ```
   - OpenResty / Nginx version (run `openresty -V` or `nginx -V`):
   - etcd version, if relevant (run `curl http://127.0.0.1:9090/v1/server_info`): it's mocked etcd in apisix-ingress-controller
   - APISIX Dashboard version, if relevant:
   - Plugin runner version, for issues related to plugin runners:
   - LuaRocks version, for installation issues (run `luarocks --version`):
   


-- 
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: notifications-unsubscribe@apisix.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] bug: apisix report error log "attempt to index field 'body' (a nil value)" [apisix]

Posted by "FeiYing9 (via GitHub)" <gi...@apache.org>.
FeiYing9 commented on issue #12171:
URL: https://github.com/apache/apisix/issues/12171#issuecomment-2820794216

   I solved this problem by add config like this:
   ```yaml
   plugin_attr:
         server-info: # Plugin: server-info
           report_ttl: 60                    # Set the TTL in seconds for server info in etcd.
           # Maximum: 86400. Minimum: 3.
   ```


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] bug: apisix report error log "attempt to index field 'body' (a nil value)" [apisix]

Posted by "FeiYing9 (via GitHub)" <gi...@apache.org>.
FeiYing9 closed issue #12171: bug: apisix report error log "attempt to index field 'body' (a nil value)"
URL: https://github.com/apache/apisix/issues/12171


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] bug: apisix report error log "attempt to index field 'body' (a nil value)" [apisix]

Posted by "FeiYing9 (via GitHub)" <gi...@apache.org>.
FeiYing9 commented on issue #12171:
URL: https://github.com/apache/apisix/issues/12171#issuecomment-2821392651

   I this this parameter should hava a default value


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] bug: apisix report error log "attempt to index field 'body' (a nil value)" [apisix]

Posted by "FeiYing9 (via GitHub)" <gi...@apache.org>.
FeiYing9 commented on issue #12171:
URL: https://github.com/apache/apisix/issues/12171#issuecomment-2820686978

   i have try different apisix version about `apache/apisix:3.50-debian` \ `apache/apisix:3.7.0-debian`, they have the same behavior


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] bug: apisix report error log "attempt to index field 'body' (a nil value)" [apisix]

Posted by "Baoyuantop (via GitHub)" <gi...@apache.org>.
Baoyuantop commented on issue #12171:
URL: https://github.com/apache/apisix/issues/12171#issuecomment-2875764166

   If there is still a problem, please open it again.


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] bug: apisix report error log "attempt to index field 'body' (a nil value)" [apisix]

Posted by "Revolyssup (via GitHub)" <gi...@apache.org>.
Revolyssup commented on issue #12171:
URL: https://github.com/apache/apisix/issues/12171#issuecomment-2850106609

   > I this this parameter should hava a default value
   
   It already has a default value of 36


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] bug: apisix report error log "attempt to index field 'body' (a nil value)" [apisix]

Posted by "Baoyuantop (via GitHub)" <gi...@apache.org>.
Baoyuantop closed issue #12171: bug: apisix report error log "attempt to index field 'body' (a nil value)"
URL: https://github.com/apache/apisix/issues/12171


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org