From 3e0247564382ade707e14a053aa40f65b97bf4fe Mon Sep 17 00:00:00 2001 From: WitteShadovv Date: Fri, 16 Oct 2026 13:32:48 +0200 Subject: [PATCH] fix(api): fix inverted check in ready endpoint GET /api/v1/ready returned "portmaster is not ready" (425) when Portmaster was ready, and "Portmaster is ready." while it was still starting. Nothing in the UI calls it at the moment (DebugAPI.ready() is unused), so this only affects external tools that wait for Portmaster to finish starting. --- base/api/endpoints_debug.go | 2 +- base/api/endpoints_debug_test.go | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 base/api/endpoints_debug_test.go diff --git a/base/api/endpoints_debug.go b/base/api/endpoints_debug.go index 06de4cd5a..c24cd72c6 100644 --- a/base/api/endpoints_debug.go +++ b/base/api/endpoints_debug.go @@ -135,7 +135,7 @@ func ping(ar *Request) (msg string, err error) { // ready checks if Portmaster has completed starting. func ready(ar *Request) (msg string, err error) { - if module.instance.Ready() { + if !module.instance.Ready() { return "", ErrorWithStatus(errors.New("portmaster is not ready, reload (F5) to try again"), http.StatusTooEarly) } return "Portmaster is ready.", nil diff --git a/base/api/endpoints_debug_test.go b/base/api/endpoints_debug_test.go new file mode 100644 index 000000000..6ddbdf60b --- /dev/null +++ b/base/api/endpoints_debug_test.go @@ -0,0 +1,19 @@ +package api + +import ( + "testing" +) + +// TestReadyEndpoint checks that the ready endpoint reports a ready Portmaster as ready. +func TestReadyEndpoint(t *testing.T) { + t.Parallel() + + // The test instance reports that Portmaster is ready. + msg, err := ready(nil) + if err != nil { + t.Fatalf("ready endpoint failed although Portmaster is ready: %s", err) + } + if msg != "Portmaster is ready." { + t.Errorf("unexpected response: %q", msg) + } +}