Aias00 opened a new issue, #7557: URL: https://github.com/apache/shenyu/issues/7557
### Is there an existing issue for this? - [x] I have searched the existing issues ### Current Behavior [WasmLoader.getWasmExtern](https://github.com/apache/shenyu/blob/2dff2730ff399635b2bc657e21a903f391fb9df8/shenyu-plugin/shenyu-plugin-wasm-api/src/main/java/org/apache/shenyu/plugin/wasm/api/loader/WasmLoader.java#L277) calls `instance.export(funcName)` and wraps its result with `Optional.ofNullable`. Chicory 1.7.3 throws `InvalidException` for unknown exports instead of returning null. Consequently, optional `before`/`after` hooks and optional data-handler callbacks throw when absent. The missing `execute`/`doExecute` response branches are also bypassed. The existing Rust fixture exports `execute` but no `before`/`after`. Its unit test invokes `execute` directly, whereas the [gateway chain](https://github.com/apache/shenyu/blob/2dff2730ff399635b2bc657e21a903f391fb9df8/shenyu-web/src/main/java/org/apache/shenyu/web/handler/ShenyuWebHandler.java#L312) invokes the hooks. ### Expected Behavior Unknown exports produce an empty Optional. Optional hooks are skipped, and required exports use the intended ShenYu error handling. Invalid module/export types should still report genuine errors. ### Steps To Reproduce With the wasm-api test classes/resources and dependencies on the classpath, run: ```java Class<?> guest = Class.forName( "org.apache.shenyu.plugin.wasm.api.AbstractWasmPluginTest$RustWasmPlugin"); try (WasmLoader loader = new WasmLoader(guest, null)) { loader.getWasmExtern("before"); } ``` This was reproduced in JShell against the current module: ```text com.dylibso.chicory.wasm.InvalidException: Unknown export with name before ``` ### Environment ShenYu: `2.7.2-SNAPSHOT`, commit `2dff2730ff399635b2bc657e21a903f391fb9df8`; Java 17; Chicory 1.7.3. ### Anything else? The existing 24 tests across wasm-api and wasm-base pass; they do not cover absent optional hooks through the gateway chain. Please add regression cases for absent optional and required exports. Related runtime migration: #6353. -- 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]
