High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.
fix: resolve errcheck lint warnings in network export
Boschba67b485d223
diff --git a/internal/bridge/observe/network_export.go b/internal/bridge/observe/network_export.goindex 30d83ec8..963748ff 100644--- a/internal/bridge/observe/network_export.go+++ b/internal/bridge/observe/network_export.go@@ -8,7 +8,6 @@ import ("sync")-// ---------------------------------------------------------------------------// ExportEncoder — pluggable format interface// ---------------------------------------------------------------------------@@ -80,23 +79,23 @@ func ListFormats() []string {// ExportEntry is the normalized representation of a network request/response.// All export formats encode from this struct.type ExportEntry struct {- StartedDateTime string `json:"startedDateTime"`- Time float64 `json:"time"`- Request ExportRequest `json:"request"`- Response ExportResponse `json:"response"`- Timings ExportTimings `json:"timings"`+ StartedDateTime string `json:"startedDateTime"`+ Time float64 `json:"time"`+ Request ExportRequest `json:"request"`+ Response ExportResponse `json:"response"`+ Timings ExportTimings `json:"timings"`}// ExportRequest holds the request portion of an entry.type ExportRequest struct {- Method string `json:"method"`- URL string `json:"url"`- HTTPVersion string `json:"httpVersion"`- Headers []NameValuePair `json:"headers"`- QueryString []NameValuePair `json:"queryString"`- PostData *ExportPostData `json:"postData,omitempty"`- HeadersSize int `json:"headersSize"`- BodySize int `json:"bodySize"`+ Method string `json:"method"`+ URL string `json:"url"`+ HTTPVersion string `json:"httpVersion"`+ Headers []NameValuePair `json:"headers"`+ QueryString []NameValuePair `json:"queryString"`+ PostData *ExportPostData `json:"postData,omitempty"`+ HeadersSize int `json:"headersSize"`+ BodySize int `json:"bodySize"`}// ExportResponse holds the response portion of an entry.diff --git a/internal/bridge/observe/network_export_test.go b/internal/bridge/observe/network_export_test.goindex 42353ebb..455268c5 100644--- a/internal/bridge/observe/network_export_test.go+++ b/internal/bridge/observe/network_export_test.go@@ -80,9 +80,9 @@ func TestHAREncoder(t *testing.T) {// Verify valid JSONvar har struct {Log struct {- Version string `json:"version"`+ Version string `json:"version"`Creator struct{ Name string } `json:"creator"`- Entries []json.RawMessage `json:"entries"`+ Entries []json.RawMessage `json:"entries"`} `json:"log"`}if err := json.Unmarshal(buf.Bytes(), &har); err != nil {@@ -103,10 +103,12 @@ func TestHAREncoder_Empty(t *testing.T) {factory := GetFormat("har")var buf bytes.Bufferenc := factory("Test", "0")- enc.Start(&buf)- enc.Finish()+ _ = enc.Start(&buf)+ _ = enc.Finish()- var har struct{ Log struct{ Entries []json.RawMessage } }+ var har struct {+ Log struct{ Entries []json.RawMessage }+ }if err := json.Unmarshal(buf.Bytes(), &har); err != nil {t.Fatalf("invalid empty HAR: %v", err)}@@ -124,10 +126,10 @@ func TestNDJSONEncoder(t *testing.T) {entry := makeTestExportEntry()var buf bytes.Bufferenc := factory("", "")- enc.Start(&buf)- enc.Encode(entry)- enc.Encode(entry)- enc.Finish()+ _ = enc.Start(&buf)+ _ = enc.Encode(entry)+ _ = enc.Encode(entry)+ _ = enc.Finish()lines := strings.Split(strings.TrimSpace(buf.String()), "\n")if len(lines) != 2 {diff --git a/internal/handlers/network_export.go b/internal/handlers/network_export.goindex 7f133cf9..315f4bdd 100644--- a/internal/handlers/network_export.go+++ b/internal/handlers/network_export.go@@ -202,29 +202,29 @@ func (h *Handlers) writeExportFile(}if err := enc.Start(f); err != nil {- f.Close()- os.Remove(tmpPath)+ _ = f.Close()+ _ = os.Remove(tmpPath)return err}for _, entry := range entries {if err := enc.Encode(entry); err != nil {- f.Close()- os.Remove(tmpPath)+ _ = f.Close()+ _ = os.Remove(tmpPath)return err}}if err := enc.Finish(); err != nil {- f.Close()- os.Remove(tmpPath)+ _ = f.Close()+ _ = os.Remove(tmpPath)return err}if err := f.Close(); err != nil {- os.Remove(tmpPath)+ _ = os.Remove(tmpPath)return err}if err := os.Rename(tmpPath, absPath); err != nil {- os.Remove(tmpPath)+ _ = os.Remove(tmpPath)return err}@@ -344,8 +344,8 @@ func (h *Handlers) HandleNetworkExportStream(w http.ResponseWriter, r *http.Requenc := factory("PinchTab", h.version())if err := enc.Start(f); err != nil {- f.Close()- os.Remove(tmpPath)+ _ = f.Close()+ _ = os.Remove(tmpPath)httpx.Error(w, 500, fmt.Errorf("start encoder: %w", err))return}@@ -358,8 +358,8 @@ func (h *Handlers) HandleNetworkExportStream(w http.ResponseWriter, r *http.Requflusher, ok := w.(http.Flusher)if !ok {_ = enc.Finish()- f.Close()- os.Remove(tmpPath)+ _ = f.Close()+ _ = os.Remove(tmpPath)httpx.Error(w, 500, fmt.Errorf("streaming not supported"))return}@@ -383,12 +383,12 @@ func (h *Handlers) HandleNetworkExportStream(w http.ResponseWriter, r *http.Requif err := f.Close(); err == nil {// Atomic rename on success (#8)if count > 0 {- os.Rename(tmpPath, absPath)+ _ = os.Rename(tmpPath, absPath)} else {- os.Remove(tmpPath)+ _ = os.Remove(tmpPath)}} else {- os.Remove(tmpPath)+ _ = os.Remove(tmpPath)}})}@@ -404,7 +404,7 @@ func (h *Handlers) HandleNetworkExportStream(w http.ResponseWriter, r *http.Requif !ok {finalize()data, _ := json.Marshal(map[string]any{"entries": count, "path": absPath})- fmt.Fprintf(w, "event: done\ndata: %s\n\n", data)+ _, _ = fmt.Fprintf(w, "event: done\ndata: %s\n\n", data)flusher.Flush()return}@@ -462,11 +462,11 @@ func (h *Handlers) HandleNetworkExportStream(w http.ResponseWriter, r *http.Requ}count++data, _ := json.Marshal(map[string]any{"entries": count, "url": safetruncateURL(entry.URL)})- fmt.Fprintf(w, "event: export\ndata: %s\n\n", data)+ _, _ = fmt.Fprintf(w, "event: export\ndata: %s\n\n", data)flusher.Flush()case <-keepalive.C:- fmt.Fprintf(w, ": keepalive\n\n")+ _, _ = fmt.Fprintf(w, ": keepalive\n\n")flusher.Flush()}}@@ -543,4 +543,3 @@ func safetruncateURL(u string) string {}return u[:maxLen]}-