You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "wangchengxu (via GitHub)" <gi...@apache.org> on 2025/03/27 10:24:28 UTC

[I] bug: schema validate failed: schema not found, path:plugins.xxx [apisix]

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

   ### Current Behavior
   
   Write a custom idempot.lua, save it and get an error: schema validate failed: schema not found, path:plugins.custom-idempot
   
   ![Image](https://github.com/user-attachments/assets/d2b0d830-a770-4055-b70e-3871a3e6b417)
   
   ### Expected Behavior
   
   _No response_
   
   ### Error Logs
   
   _No response_
   
   ### Steps to Reproduce
   
   1. Writing a custom idempot.lua
   2. Save the apisix rule
   
   ### Environment
   
   - APISIX version: 3.9.1
   - Operating system: Linux apisix-control-plane-7b97488c96-2qqn8 6.1.128 #1 SMP PREEMPT_DYNAMIC Wed Feb 26 21:46:15 UTC 2025 x86_64 GNU/Linux
   - OpenResty / Nginx version (run `openresty -V` or `nginx -V`): nginx version: openresty/1.25.3.1
   - etcd version, if relevant (run `curl http://127.0.0.1:9090/v1/server_info`):
   - APISIX Dashboard version, if relevant:
   - Plugin runner version, for issues related to plugin runners:
   - LuaRocks version, for installation issues (run `luarocks --version`): 3.8.0
   


-- 
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: schema validate failed: schema not found, path:plugins.xxx [apisix]

Posted by "Baoyuantop (via GitHub)" <gi...@apache.org>.
Baoyuantop closed issue #12095: bug: schema validate failed: schema not found, path:plugins.xxx
URL: https://github.com/apache/apisix/issues/12095


-- 
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: schema validate failed: schema not found, path:plugins.xxx [apisix]

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

   This my apisix config.yaml:
   ```
   plugin_attr:
     opentelemetry:
       set_ngx_var: true
       resource:
         service.name: APISIX
       collector:
         address: tempo.tempo:4318
     custom-idempotent:
       file_path: /usr/local/apisix/custom_plugins/custom-idempotent.lua
   plugins:
     - openid-connect
     - opa
     - opentelemetry
     - response-rewrite
     - limit-count
     - proxy-rewrite
     - serverless-post-function
     - response-rewrite
     - custom-idempotent
   custom_plugins:
     - custom-idempotent
   nginx_config:
     error_log: /dev/stderr
     stream:
       access_log: /dev/stdout
     http:
       access_log: /dev/stdout
       access_log_format: '$remote_addr - $remote_user [$time_local] $host "$request" $status $body_bytes_sent $request_time "$http_referer" "$http_user_agent" $upstream_addr $upstream_status $upstream_response_time "$upstream_http_referer" "$opentelemetry_trace_id"'
     http_configuration_snippet: |
       proxy_buffer_size 128k;
       proxy_buffers 32 128k;
       proxy_busy_buffers_size 128k;
     http_server_configuration_snippet: |
       proxy_buffer_size 128k;
       proxy_buffers 32 128k;
       proxy_busy_buffers_size 128k;
   apisix:
     control:
       ip: 0.0.0.0
       port: 9090
     extra_lua_path: /usr/local/apisix/custom_plugins/?.lua
   deployment:
     role: traditional
     role_control_plane:
       config_provider: etcd
       conf_server:
         listen: 0.0.0.0:9280
         cert: /bitnami/certs/tls.crt
         cert_key: /bitnami/certs/tls.key
     etcd:
       host:
         - http://etcd:2379
       prefix: /apisix
       timeout: 30
       use_grpc: false
       startup_retry: 60
       user: "root"
       password: "AiDmEtGYUV"
     certs:
       cert: /bitnami/certs/tls.crt
       cert_key: /bitnami/certs/tls.key
       client_ca_cert: /bitnami/certs/ca.crt
     admin:
       # https_admin: true
       # admin_api_mtls:
       # admin_ssl_cert: /bitnami/certs/tls.crt
       #  admin_ssl_cert_key: /bitnami/certs/tls.key
       allow_admin:
         - 0.0.0.0/0
         - 127.0.0.0/24
       admin_key:
         - name: admin
           key: "feedc9f034335f136f87ad84b625c8f1"
           role: admin
         - name: viewer
           key: "deedf7cf07e344346cd3f287985e76a2"
           role: viewer
       admin_listen:
         port: 9180
       enable_admin_cors: true # Admin API support CORS response headers.
     role_traditional:
       config_provider: etcd
   discovery:
     kubernetes:
       service:
         schema: https #default https
         # apiserver host, options [ipv4, ipv6, domain, environment variable]
         host: ${KUBERNETES_SERVICE_HOST}
         # apiserver port, options [port number, environment variable]
         port: ${KUBERNETES_SERVICE_PORT}
       client:
         # serviceaccount token or token_file
         token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
       default_weight: 50 # weight assigned to each discovered endpoint. default 50, minimum 0
   ```
   I hope forward to getting support and answers from technical teachers. Thank you.


-- 
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: schema validate failed: schema not found, path:plugins.xxx [apisix]

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

   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: schema validate failed: schema not found, path:plugins.xxx [apisix]

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

   https://github.com/apache/apisix-dashboard/blob/master/docs/en/latest/FAQ.md#4-after-modifying-the-plugin-schema-or-creating-a-custom-plugin-in-apache-apisix-why-cant-i-find-it-on-the-dashboard


-- 
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: schema validate failed: schema not found, path:plugins.xxx [apisix]

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

   > Hi [@wangchengxu](https://github.com/wangchengxu), Is the problem solved?
   
   @Baoyuantop Thank you for your guidance, but I still haven't been able to resolve this issue.
   
   


-- 
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: schema validate failed: schema not found, path:plugins.xxx [apisix]

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

   Hi @wangchengxu, Is the problem solved?


-- 
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: schema validate failed: schema not found, path:plugins.xxx [apisix]

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

   From the error message in your screenshot, it looks like the jsonschema in the dashboard is not being updated to recognize your custom plugin.


-- 
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: schema validate failed: schema not found, path:plugins.xxx [apisix]

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

   This is my lua script:
   ```
   local core = require("apisix.core")
   local redis_new = require("resty.redis").new
   
   local plugin_name = "custom-idempotent"
   
   -- Plugin schema for route-level config
   local schema = {
       type = "object",
       properties = {
           host = { type = "string", description = "Redis host", default = "127.0.0.1" },
           port = { type = "integer", description = "Redis port", default = 6379 },
           ttl = { type = "integer", description = "Key expiration time (seconds)", default = 3600 },
           strict_mode = { type = "boolean", description = "Strict mode for request hash match", default = true }
       },
       additionalProperties = false
   }
   
   local _M = {
       version = 1.0,
       priority = 800,
       name = plugin_name,
       schema = schema
   }
   
   -- Converts Redis HGETALL result to Lua table
   local function normalize_hgetall_result(data)
       local res = {}
       for index, value in ipairs(data) do
           if index % 2 == 1 then
               res[value] = data[index + 1]
           end
       end
       return res
   end
   
   -- Generates a base64 hash of the request
   local function hash_request(ctx)
       local request = {
           method = core.request.get_method(),
           uri = ctx.var.request_uri,
           headers = core.request.headers(),
           body = core.request.get_body()
       }
       local json = core.json.stably_encode(request)
       return ngx.encode_base64(json)
   end
   
   -- Gets Request-Id header or fallback to ctx.var
   local function get_request_id(ctx)
       return core.request.header(ctx, "Request-Id") or ctx.var.request_id
   end
   
   -- Gets Request-Time header or generate UTC ISO8601
   local function get_request_time(ctx)
       local t = core.request.header(ctx, "Request-Time")
       if t then return t end
       local utc = os.date("!*t")
       return string.format("%04d-%02d-%02dT%02d:%02d:%02dZ",
           utc.year, utc.month, utc.day, utc.hour, utc.min, utc.sec)
   end
   
   -- Establish Redis connection
   local function get_redis_connection(conf)
       local red = redis_new()
       red:set_timeout(1000)
       local ok, err = red:connect(conf.host, conf.port)
       if not ok then
           return nil, "Redis connection error: " .. (err or "unknown")
       end
       return red
   end
   
   -- Access phase handler
   function _M.access(conf, ctx)
       local ok, err = core.schema.check(schema, conf)
       if not ok then
           core.log.error("Invalid plugin conf: ", err)
           return core.response.exit(500, "Invalid plugin config")
       end
   
       local request_id = get_request_id(ctx)
       if not request_id then
           return core.response.exit(400, "Missing Request-Id")
       end
   
       local request_time = get_request_time(ctx)
       local request_hash = hash_request(ctx)
       local redis_key = "idempotent#" .. request_id
   
       local red, err = get_redis_connection(conf)
       if not red then
           core.log.error(err)
           return core.response.exit(500, "Redis unavailable")
       end
   
       local resp, err = red:hgetall(redis_key)
       if not resp then
           core.log.error("Redis hgetall error: ", err)
           return core.response.exit(500)
       end
   
       if next(resp) == nil then
           red:hset(redis_key, "request", request_hash)
           red:hset(redis_key, "request_id", request_id)
           red:hset(redis_key, "request_time", request_time)
           red:expire(redis_key, conf.ttl or 3600)
       else
           local data = normalize_hgetall_result(resp)
           local stored_hash = data["request"]
   
           if conf.strict_mode and stored_hash and request_hash ~= stored_hash then
               return core.response.exit(422, {
                   message = "Request-Id cannot be reused for different payloads",
                   request_id = request_id
               })
           end
   
           if not data["response"] then
               return core.response.exit(409, {
                   message = "Request is already being processed",
                   request_id = request_id,
                   request_time = data["request_time"]
               })
           end
   
           local cached = core.json.decode(data["response"])
           for k, v in pairs(cached["headers"] or {}) do
               core.response.set_header(k, v)
           end
           return core.response.exit(cached["status"], cached["body"])
       end
   end
   
   -- body_filter phase: cache the response
   function _M.body_filter(conf, ctx)
       local request_id = core.request.header(ctx, "Request-Id")
       if not request_id then return end
   
       local redis_key = "idempotent#" .. request_id
       local red, err = get_redis_connection(conf)
       if not red then
           core.log.error("Redis error in body_filter: ", err)
           return
       end
   
       local response = {
           status = ngx.status,
           body = core.response.hold_body_chunk(ctx, true),
           headers = ngx.resp.get_headers()
       }
   
       local ok, err = red:hset(redis_key, "response", core.json.encode(response))
       if not ok then
           core.log.error("Failed to save response to Redis: ", err)
           return
       end
   
       red:expire(redis_key, conf.ttl or 3600)
   end
   
   return _M
   ```


-- 
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: schema validate failed: schema not found, path:plugins.xxx [apisix]

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

   ![Image](https://github.com/user-attachments/assets/99d9fbf3-344b-488a-82e0-4b2554ded03b)
   I tried to copy the custom script to the plugins path of apisix, but encountered a read-only problem, but I have specified the corresponding custom lua path in config.yaml. I am not sure if this is the cause of the problem


-- 
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