{"record":{"id":"f8960e51d51c1cb1","repo":"router-for-me/CLIProxyAPI","slug":"cliproxy-plugin-init-returned-d-v","errorCode":null,"errorMessage":"cliproxy_plugin_init returned %d: %v","messagePattern":"cliproxy_plugin_init returned (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/pluginhost/loader_windows.go","lineNumber":105,"sourceCode":"\tid := windowsHostCallbackID.Add(1)\n\thostCtx := new(uintptr)\n\t*hostCtx = id\n\twindowsHostCallbackEntries.Store(id, dynamicHostCallbackEntry{host: host, pluginID: file.ID})\n\tclient := &dynamicLibraryClient{\n\t\tdll:      dll,\n\t\ttempPath: loadPath,\n\t\thostCtx:  hostCtx,\n\t\thostAPI: &windowsHostAPI{\n\t\t\tabiVersion: pluginHostABIVersion,\n\t\t\thostCtx:    uintptr(unsafe.Pointer(hostCtx)),\n\t\t\tcall:       windowsHostCallCallback,\n\t\t\tfreeBuffer: windowsHostFreeCallback,\n\t\t},\n\t}\n\trc, _, errCall := proc.Call(uintptr(unsafe.Pointer(client.hostAPI)), uintptr(unsafe.Pointer(&client.api)))\n\tif rc != 0 {\n\t\tclient.closeAfterOpenFailure()\n\t\treturn nil, fmt.Errorf(\"cliproxy_plugin_init returned %d: %v\", rc, errCall)\n\t}\n\tif client.api.abiVersion != pluginHostABIVersion {\n\t\tclient.closeAfterOpenFailure()\n\t\treturn nil, fmt.Errorf(\"plugin ABI version %d is not supported\", client.api.abiVersion)\n\t}\n\tif client.api.call == 0 || client.api.freeBuffer == 0 {\n\t\tclient.closeAfterOpenFailure()\n\t\treturn nil, fmt.Errorf(\"plugin function table is incomplete\")\n\t}\n\treturn client, nil\n}\n\nfunc shadowCopyPlugin(file pluginFile) (string, error) {\n\tdir, errDir := shadowPluginDir()\n\tif errDir != nil {\n\t\treturn \"\", errDir\n\t}\n\tshadowPluginCleanupOnce.Do(func() {","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/router-for-me/CLIProxyAPI/blob/78f0c4079e3e6273d65d03b5549cffc898703264/internal/pluginhost/loader_windows.go#L87-L123","documentation":"On Windows, the host resolves and calls the cliproxy_plugin_init export in the plugin DLL via syscall; a nonzero return code triggers this error. It means the plugin's initialization function itself failed (the errCall component is the syscall.LastError, usually not the plugin's reason). The client is closed via closeAfterOpenFailure.","triggerScenarios":"DLL's init returns nonzero because of missing runtime dependencies (VC++ redistributable), failed internal initialization, architecture mismatch (32-bit DLL in 64-bit host), or the DLL not actually exporting a working cliproxy_plugin_init.","commonSituations":"Plugin compiled with a different toolchain than expected; dependent DLLs not next to the shadow-copied plugin; plugin built for a different ABI of the plugin SDK whose init rejects the host API struct.","solutions":["Test the DLL in isolation (rundll32 or a small harness) to see whether cliproxy_plugin_init succeeds and which dependency fails","Rebuild the plugin with the same toolchain/architecture (GOARCH amd64 vs 386) as the host process","Place dependent DLLs alongside the original plugin artifact or link the plugin statically","Rebuild the plugin against the pluginhost SDK version matching the server"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"client, err := loader.Open(file, host)\nif err != nil {\n    log.WithError(err).WithField(\"plugin\", file.Path).Error(\"plugin init failed\")\n    continue // skip plugin, keep server up\n}","preventionTips":["Verify DLL exports with dumpbin /exports before deploying","Keep the plugin's runtime dependencies beside the artifact","Match host and plugin architecture (amd64/386)"],"tags":["plugin","windows","dll","dynamic-library"],"backgroundTag":null,"analyzedSha":"78f0c4079e3e6273d65d03b5549cffc898703264","analyzedAt":"2026-08-15T12:26:37.444Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}