Closed nilslice closed 3 months ago
tagging @zshipko to take a look 🙏
interesting, it sounds similar to some of the other memory-related things i've been looking at - I will do some debugging tomorrow to try to figure this out!
Thank you!
Thanks to @zshipko's quick fix, this is resolved in the latest version -- please update your Python SDK to v1.0.2.
plugin.call
will now raise using the error output from a plugin call to set the error message e.g.
SDK:
import extism
manifest = {"wasm": [{"path": "plugins/zig-example/zig-out/bin/zig-pdk-template.wasm"}]}
with extism.Plugin(manifest, wasi=True) as plugin:
try:
output = plugin.call(
"run",
"hello world",
)
except extism.Error as e:
print("extism error caught:", e)
PDK:
const std = @import("std");
const extism_pdk = @import("extism-pdk");
const Plugin = extism_pdk.Plugin;
const allocator = std.heap.wasm_allocator;
export fn run() i32 {
const plugin = Plugin.init(allocator);
const name = plugin.getInput() catch unreachable;
defer allocator.free(name);
const output = std.fmt.allocPrint(allocator, "ERROR> Hello, {s}!", .{name}) catch unreachable;
plugin.setError(output);
return -1;
}
(cc @ethanholz)
I caught a stream at https://www.twitch.tv/ninja_tron where a bug was discovered... setError in the Zig PDK doesn't seem to get the correct output to Python SDK (at least in this case). It may also effect other SDKs, so we should test that.
I'm not sure if it is a bug in the Python SDK or the Zig PDK, so just opening it here to track and more easily create a repro.
The Python SDK did get some output when the error was written from the Zig PDK, but it was the wrong string from memory.