High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.
fix: resolve E2E failures — prefix state load, CLI runner multi-stage build, gofmt
Yash Jadhav1cac6619fea0
diff --git a/internal/handlers/state.go b/internal/handlers/state.goindex 4e871017..b797f65e 100644--- a/internal/handlers/state.go+++ b/internal/handlers/state.go@@ -289,8 +289,26 @@ func (h *Handlers) HandleStateLoad(w http.ResponseWriter, r *http.Request) {httpx.Error(w, 404, fmt.Errorf("no state file found for name or prefix %q", req.Name))return}- // Matches are sorted newest first; use the first.- path = state.ResolvePath(h.Config.StateDir, matches[0].Name)+ // Matches are sorted newest first; resolve the actual file path from the matched name.+ // We must call ResolvePath with the full matched name (not the prefix) so the+ // correct .json / .json.enc file is located on disk.+ resolvedPath := state.ResolvePath(h.Config.StateDir, matches[0].Name)+ if resolvedPath == "" {+ // Fallback: scan the dir directly to get the real path for this name.+ dir := state.SessionsDir(h.Config.StateDir)+ for _, ext := range []string{".json.enc", ".json"} {+ candidate := filepath.Join(dir, matches[0].Name+ext)+ if _, statErr := os.Stat(candidate); statErr == nil {+ resolvedPath = candidate+ break+ }+ }+ }+ if resolvedPath == "" {+ httpx.Error(w, 404, fmt.Errorf("state file for prefix %q found in index but not on disk", req.Name))+ return+ }+ path = resolvedPath}sf, err := state.Load(path, encryptionKey)diff --git a/internal/handlers/storage_test.go b/internal/handlers/storage_test.goindex 47d3a70e..c64a7a44 100644--- a/internal/handlers/storage_test.go+++ b/internal/handlers/storage_test.go@@ -2,9 +2,9 @@ package handlersimport ("bytes"+ "github.com/pinchtab/pinchtab/internal/config""net/http/httptest""testing"- "github.com/pinchtab/pinchtab/internal/config")func TestHandleStorageDelete_EmptyBody(t *testing.T) {@@ -24,8 +24,8 @@ func TestHandleStorageDelete_EmptyBody(t *testing.T) {if w.Code == 400 {t.Fatalf("expected handleStorageDelete to handle empty body, got 400: %s", w.Body.String())}-- // If it got past decode, it should try to find a tab.++ // If it got past decode, it should try to find a tab.// Our mockBridge return a context for any tabID, so it should proceed to domain check.// We expect 200 if the mock allows it.if w.Code != 200 && w.Code != 404 {diff --git a/tests/e2e/docker-compose.yml b/tests/e2e/docker-compose.ymlindex b4e01435..49c5c412 100644--- a/tests/e2e/docker-compose.yml+++ b/tests/e2e/docker-compose.yml@@ -51,7 +51,8 @@ services:runner-cli:build:- context: ./runner-cli+ context: ../..+ dockerfile: tests/e2e/runner-cli/Dockerfiledepends_on:pinchtab:condition: service_healthydiff --git a/tests/e2e/runner-cli/Dockerfile b/tests/e2e/runner-cli/Dockerfileindex fcb37bda..c77a80ce 100644--- a/tests/e2e/runner-cli/Dockerfile+++ b/tests/e2e/runner-cli/Dockerfile@@ -1,23 +1,44 @@-# CLI E2E test runner-# Includes pinchtab binary for testing CLI commands+# CLI E2E test runner — multi-stage build so the pinchtab binary is always+# present, correctly-architected, and executable inside the container.+ARG TARGETARCH=amd64++# ── Build stage ───────────────────────────────────────────────────────────────+FROM golang:1.24-alpine AS build+WORKDIR /src++# Install git for modules that need VCS metadata+RUN apk add --no-cache git++# Dependency layer (cached unless go.mod/go.sum change)+COPY go.mod go.sum ./+RUN go mod download++# Copy full source and build the CLI binary+COPY . .+RUN CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /out/pinchtab ./cmd/pinchtab++# ── Runner image ──────────────────────────────────────────────────────────────FROM alpine:3.21-# Install test dependenciesRUN apk add --no-cache \bash \curl \jq \- coreutils+ coreutils \+ ca-certificates-# Copy pre-built pinchtab binary (built by CI before docker build)-COPY pinchtab /usr/local/bin/pinchtab+# Copy the freshly-built binary from the build stage+COPY --from=build /out/pinchtab /usr/local/bin/pinchtabRUN chmod +x /usr/local/bin/pinchtab+# Sanity-check: bail early with a clear message if the binary is broken/missing+RUN pinchtab --version 2>/dev/null || { echo "ERROR: pinchtab binary not runnable after build"; exit 1; }+# Create results directoryRUN mkdir -p /resultsWORKDIR /e2e-# Default command runs all tests+# Default: run all CLI testsCMD ["/bin/bash", "/e2e/run.sh", "cli", "all=true"]