Skip to content

fix: remove unwrap() from extism_compiled_plugin_new #794

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 26, 2024

Conversation

chrisdickinson
Copy link
Contributor

extism_compiled_plugin_new would panic on bad manifest input (there's a test in the python sdk 1 that hits this directly.) Catch the error and set errmsg appropriately instead.

Additionally: golf the function pointer casting for the various plugin_new calls, with the goal of reducing the number of allocations by leaning on iterator size hints (and reducing the scope of unsafe{} use.) This introduces a breaking change. Previously NULL values were silently accepted in the functions** list; now they fail. This maintains consistency with behavior on "consumed" ExtismFunction pointer.

`extism_compiled_plugin_new` would panic on bad manifest input (there's
a test in the python sdk [1] that hits this directly.) Catch the error and
set `errmsg` appropriately instead.

Additionally: golf the function pointer casting for the various `plugin_new` calls,
with the goal of reducing the number of allocations by leaning on iterator size
hints (and reducing the scope of `unsafe{}` use.) This part can be severed: it
introduces a breaking change. Previously `NULL` values were silently accepted in
the `functions**` list; now they fail. This maintains consistency with behavior on
"consumed" `ExtismFunction` pointer.

[1]: https://github.com/extism/python-sdk/blob/main/tests/test_extism.py#L50-L53
Copy link
Contributor

@zshipko zshipko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks!

@chrisdickinson chrisdickinson merged commit 4db57de into main Nov 26, 2024
5 checks passed
@chrisdickinson chrisdickinson deleted the chris/20241125-catch-compiled-plugin-errors branch November 26, 2024 00:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants