fix: AI feature install failures — missing rembg session and Fastify 415 (#102, #103)

Register custom BiRefNet-matting ONNX session in install_feature.py so
rembg.new_session("birefnet-matting") no longer raises ValueError during
on-demand installs. The session was already registered in remove_bg.py
(runtime) and download_models.py (build-time) but was missed in the
install path, causing background-removal bundle installs to always fail.

Send JSON body on install/uninstall POST requests to avoid Fastify 5's
strict content-type parser rejecting body-less POSTs with 415.

Fix error message extraction to preserve structured {"error": ...} JSON
from the Python script and filter out pthread_setaffinity_np noise.
This commit is contained in:
SnapOtter
2026-04-27 02:38:17 +08:00
parent 02a84b8741
commit 4f81b29fbc
4 changed files with 75 additions and 9 deletions
+4 -4
View File
@@ -1966,7 +1966,7 @@ describe("useFeaturesStore", () => {
await useFeaturesStore.getState().uninstallBundle("ai-rembg");
expect(mockApiPost).toHaveBeenCalledWith("/v1/admin/features/ai-rembg/uninstall");
expect(mockApiPost).toHaveBeenCalledWith("/v1/admin/features/ai-rembg/uninstall", {});
});
it("uninstallBundle sets error on failure", async () => {
@@ -2207,8 +2207,8 @@ describe("useFeaturesStore", () => {
await useFeaturesStore.getState().reinstallBundle("ai-rembg");
expect(mockApiPost).toHaveBeenCalledWith("/v1/admin/features/ai-rembg/uninstall");
expect(mockApiPost).toHaveBeenCalledWith("/v1/admin/features/ai-rembg/install");
expect(mockApiPost).toHaveBeenCalledWith("/v1/admin/features/ai-rembg/uninstall", {});
expect(mockApiPost).toHaveBeenCalledWith("/v1/admin/features/ai-rembg/install", {});
});
// -- EventSource progress handling ----------------------------------------
@@ -2452,7 +2452,7 @@ describe("useFeaturesStore", () => {
expect(useFeaturesStore.getState().installAllActive).toBe(false);
expect(useFeaturesStore.getState().queued).toEqual([]);
// Only not-installed bundle should have been installed
expect(mockApiPost).toHaveBeenCalledWith("/v1/admin/features/ai-rembg/install");
expect(mockApiPost).toHaveBeenCalledWith("/v1/admin/features/ai-rembg/install", {});
});
it("installAll skips bundles that are already installed", async () => {