Skip to content

High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.

fix: config set browser.proxy.username/password/bypassList/geo.* is… (PIN-178)

Luigi Agosti9d41b00b54e1
diff --git a/docs/reference/config.md b/docs/reference/config.md
index 36af943f..9bbb7885 100644
--- a/docs/reference/config.md
+++ b/docs/reference/config.md
@@ -433,6 +433,15 @@ on top of CloakBrowser's native patches.
Advanced CloakBrowser flags can still go through `browser.extraFlags` when they
are not PinchTab-owned lifecycle flags.
+`browser.proxy.server` is the prerequisite for the rest of the block:
+`browser.proxy.username`, `password`, `bypassList` and every `browser.proxy.geo.*`
+key do nothing without it, because there is no proxy to route through,
+authenticate to, or align geo with. The values are still kept — `config set`
+writes them, `config get` returns them, and setting the server afterwards makes
+them take effect — and PinchTab reports the incomplete block on each config read
+or write until a server is set. Clearing `browser.proxy.server` turns the proxy
+off and leaves the other values on disk for the next server.
+
`browser.proxy.geo` is a CloakBrowser fingerprint-alignment hint. When a proxy
server and geo block are configured for a CloakBrowser target, PinchTab maps the
geo values into native CloakBrowser fingerprint flags unless the target already
diff --git a/internal/bridge/runtime/init.go b/internal/bridge/runtime/init.go
index 303eb4de..a45ba63b 100644
--- a/internal/bridge/runtime/init.go
+++ b/internal/bridge/runtime/init.go
@@ -305,7 +305,9 @@ func geoProviderForConfig(cfg *config.RuntimeConfig) geo.Provider {
}
func resolveLaunchGeoAlignment(parent context.Context, cfg *config.RuntimeConfig) (launchGeoAlignment, error) {
- if cfg == nil || cfg.Proxy.IsZero() || cfg.Proxy.Geo == nil || cfg.Proxy.Geo.IsZero() {
+ // HasNoServer, not IsZero: launch alignment matches geo to the PROXY's egress, so
+ // with no server there is no egress to align with.
+ if cfg == nil || cfg.Proxy.HasNoServer() || cfg.Proxy.Geo == nil || cfg.Proxy.Geo.IsZero() {
return launchGeoAlignment{}, nil
}
if !config.CloakBrowserActive(cfg) {
diff --git a/internal/bridge/runtime/proxy_auth.go b/internal/bridge/runtime/proxy_auth.go
index 8b860822..304330a6 100644
--- a/internal/bridge/runtime/proxy_auth.go
+++ b/internal/bridge/runtime/proxy_auth.go
@@ -14,7 +14,9 @@ import (
// ProxyAuthEnabled is the single gate for the CDP credential path
// (testable without a running Chrome).
func ProxyAuthEnabled(p config.BrowserProxyConfig) bool {
- if p.IsZero() {
+ // HasNoServer, not IsZero: credentials with no server describe no proxy to
+ // authenticate to, so there is nothing for the CDP path to answer.
+ if p.HasNoServer() {
return false
}
return p.Username != ""
diff --git a/internal/bridge/runtime/proxy_auth_test.go b/internal/bridge/runtime/proxy_auth_test.go
index 16137a96..df5ec29c 100644
--- a/internal/bridge/runtime/proxy_auth_test.go
+++ b/internal/bridge/runtime/proxy_auth_test.go
@@ -246,3 +246,19 @@ func captureSlog(t *testing.T, fn func()) string {
fn()
return buf.String()
}
+
+// The CDP credential path asks "is there a proxy to authenticate to", which is a
+// different question from "is anything set": a block holding credentials and no server
+// is kept on disk and reported to the operator, but there is nothing to answer for it.
+func TestProxyAuthNeedsAServerNotJustCredentials(t *testing.T) {
+ credentialsOnly := config.BrowserProxyConfig{Username: "bob", Password: "hunter2"}
+ if ProxyAuthEnabled(credentialsOnly) {
+ t.Error("proxy auth is enabled with credentials and no server, so a Fetch listener runs for a proxy that does not exist")
+ }
+
+ completed := credentialsOnly
+ completed.Server = "http://proxy.example:8080"
+ if !ProxyAuthEnabled(completed) {
+ t.Error("proxy auth is not enabled once the server is set, so credentials set before the server stay unused")
+ }
+}
diff --git a/internal/config/browser_proxy.go b/internal/config/browser_proxy.go
index 5b6a0f72..660723d7 100644
--- a/internal/config/browser_proxy.go
+++ b/internal/config/browser_proxy.go
@@ -1,6 +1,7 @@
package config
import (
+ "encoding/json"
"fmt"
"net"
"strconv"
@@ -13,7 +14,9 @@ import (
//
// Server is "<scheme>://<host>:<port>" (http, https, socks4, socks5); embedded
// credentials are rejected — use Username/Password. Empty Server disables the
-// proxy and ignores other fields. Proxy auth is delivered via CDP at the
+// proxy at runtime and every other field goes unused — but the block is still
+// persisted and reported, because a value the operator set and PinchTab silently
+// discarded is the one state nobody can debug from outside. Proxy auth is delivered via CDP at the
// bridge layer (see internal/bridge/runtime/proxy_auth.go) because Chrome
// rejects credentials in --proxy-server.
type BrowserProxyConfig struct {
@@ -43,10 +46,63 @@ var validProxySchemes = map[string]struct{}{
"socks5": {},
}
+// IsZero reports whether NOTHING is set, which is the question a writer asks ("is
+// there anything to persist?") and a validator asks ("is there anything to check?").
+// It used to test the server alone and answer for the whole struct, so a proxy
+// holding only credentials, a bypass list or geo overrides counted as absent: the
+// save dropped it, `config set` reported success over a file it never changed, and
+// clearing the server on a populated proxy was discarded too — leaving the old proxy
+// in effect while the operator believed it was off.
+//
+// Written out field by field rather than as p == BrowserProxyConfig{} because the
+// struct holds a slice and a pointer, so it is not comparable — the neighbouring
+// BrowserProxyGeoConfig.IsZero can use ==, and this one cannot. Do not "simplify" it
+// back to a comparison.
func (p BrowserProxyConfig) IsZero() bool {
+ return strings.TrimSpace(p.Server) == "" &&
+ len(p.BypassList) == 0 &&
+ strings.TrimSpace(p.Username) == "" &&
+ p.Password == "" &&
+ (p.Geo == nil || p.Geo.IsZero())
+}
+
+// HasNoServer reports whether there is no proxy to send traffic through. That is a
+// DIFFERENT question from IsZero and it is the one every runtime caller wants: with
+// credentials but no server there is no proxy to launch with, none to authenticate
+// to, and no egress whose location geo should align with. Asking IsZero there would
+// send an empty server into ParseProxyServer, which refuses to launch at all.
+func (p BrowserProxyConfig) HasNoServer() bool {
return strings.TrimSpace(p.Server) == ""
}
+// MarshalJSON keeps the server key present whenever anything else in the block is set,
+// even when the server is empty — which omitempty would drop.
+//
+// That matters because of how a config is saved: the file's own shape is authoritative
+// and the writer patches it key by key from this render, so a key MISSING from the
+// render is indistinguishable from one the struct does not model, and the patcher
+// preserves those verbatim. Clearing browser.proxy.server therefore reported success
+// and left the old server on disk and in effect — the operator believed egress had
+// stopped going through the proxy while it still did. Rendering the cleared server as
+// "" is what makes turning a proxy off actually reach the file.
+//
+// A block with nothing in it still renders empty, so an unused proxy does not grow a
+// server key.
+func (p BrowserProxyConfig) MarshalJSON() ([]byte, error) {
+ type plain BrowserProxyConfig
+ raw, err := json.Marshal(plain(p))
+ if err != nil || p.IsZero() || !p.HasNoServer() {
+ return raw, err
+ }
+
+ fields := map[string]json.RawMessage{}
+ if err := json.Unmarshal(raw, &fields); err != nil {
+ return nil, err
+ }
+ fields["server"] = json.RawMessage(`""`)
+ return json.Marshal(fields)
+}
+
// Redacted keeps empty Password empty so callers can distinguish absent vs hidden.
func (p BrowserProxyConfig) Redacted() BrowserProxyConfig {
out := BrowserProxyConfig{
@@ -122,18 +178,25 @@ func ParseProxyServer(server string) (scheme, host string, port int, err error)
return scheme, h, portNum, nil
}
-// ValidateBrowserProxy returns nil when disabled (empty Server).
+// ValidateBrowserProxy returns nil only when nothing is set. A block with siblings
+// and no server is a misconfiguration, not an absence: it used to skip validation
+// entirely, so a bypass pattern that could never be accepted alongside a server went
+// unreported until someone set one. The missing server itself is reported as an
+// ADVISORY rather than from here — see ProxyServerRequiredAdvisory for why a
+// diagnostic that must not block the very write completing the block cannot gate.
func ValidateBrowserProxy(field string, p BrowserProxyConfig) []error {
if p.IsZero() {
return nil
}
var errs []error
- if _, _, _, err := ParseProxyServer(p.Server); err != nil {
- errs = append(errs, ValidationError{
- Field: field + ".server",
- Message: err.Error(),
- })
+ if !p.HasNoServer() {
+ if _, _, _, err := ParseProxyServer(p.Server); err != nil {
+ errs = append(errs, ValidationError{
+ Field: field + ".server",
+ Message: err.Error(),
+ })
+ }
}
for i, pat := range p.BypassList {
@@ -185,7 +248,7 @@ func ValidateBrowserProxy(field string, p BrowserProxyConfig) []error {
// would silently egress traffic from the real IP — the worst failure mode for
// users who configured a proxy for anonymity.
func BrowserProxyFlags(p BrowserProxyConfig) ([]string, error) {
- if p.IsZero() {
+ if p.HasNoServer() {
return nil, nil
}
scheme, host, port, err := ParseProxyServer(p.Server)
diff --git a/internal/config/browser_proxy_test.go b/internal/config/browser_proxy_test.go
index 62690c38..0936983b 100644
--- a/internal/config/browser_proxy_test.go
+++ b/internal/config/browser_proxy_test.go
@@ -2,6 +2,8 @@ package config
import (
"encoding/json"
+ "os"
+ "path/filepath"
"strings"
"testing"
)
@@ -526,3 +528,236 @@ func TestParseProxyServer_PathWithAtSignAccepted(t *testing.T) {
t.Fatal("embedded credentials must still be rejected")
}
}
+
+// A proxy block holding anything at all must survive a save. It did not: the whole
+// block was dropped whenever server was unset, so `config set browser.proxy.username`
+// reported success and wrote nothing — the command's own output cannot be the oracle
+// for this, which is why these read the marshalled file back.
+func TestProxyFieldsSurviveASaveWithoutAServer(t *testing.T) {
+ for _, tc := range []struct {
+ name string
+ proxy BrowserProxyConfig
+ want string
+ }{
+ {name: "username", proxy: BrowserProxyConfig{Username: "bob"}, want: "bob"},
+ {name: "password", proxy: BrowserProxyConfig{Password: "hunter2"}, want: "hunter2"},
+ {name: "bypassList", proxy: BrowserProxyConfig{BypassList: []string{"*.internal"}}, want: "*.internal"},
+ {name: "geo.timezone", proxy: BrowserProxyConfig{Geo: &BrowserProxyGeoConfig{Timezone: "Europe/Rome"}}, want: "Europe/Rome"},
+ {name: "geo.locale", proxy: BrowserProxyConfig{Geo: &BrowserProxyGeoConfig{Locale: "it-IT"}}, want: "it-IT"},
+ {name: "geo.webrtcIP", proxy: BrowserProxyConfig{Geo: &BrowserProxyGeoConfig{WebRTCIP: "1.2.3.4"}}, want: "1.2.3.4"},
+ {name: "geo.countryISO", proxy: BrowserProxyConfig{Geo: &BrowserProxyGeoConfig{CountryISO: "IT"}}, want: "IT"},
+ } {
+ t.Run(tc.name, func(t *testing.T) {
+ fc := &FileConfig{}
+ fc.Browser.Proxy = tc.proxy
+
+ raw, err := json.Marshal(fc)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !strings.Contains(string(raw), tc.want) {
+ t.Errorf("browser.proxy.%s was accepted and then dropped by the save; the marshalled config is %s", tc.name, raw)
+ }
+ })
+ }
+}
+
+// The fail-OPEN half: clearing the server on a populated proxy must be persisted, or the
+// operator believes traffic no longer egresses through the proxy while it still does.
+//
+// Driven through SaveFileConfig against a file that already exists, because that is the
+// only path where the defect lives: the save patches the file key by key from the
+// marshalled config, so an omitempty-dropped server reads as a key the struct does not
+// model and the OLD value is preserved. A test that only marshals the struct passes
+// while the shipped command still leaves the proxy on.
+func TestClearingTheServerOnAPopulatedProxyIsPersisted(t *testing.T) {
+ dir := t.TempDir()
+ path := filepath.Join(dir, "config.json")
+ if err := os.WriteFile(path, []byte(`{"browser":{"proxy":{"server":"http://p.example:8080","username":"bob","password":"hunter2","bypassList":["*.internal"]}}}`), 0600); err != nil {
+ t.Fatal(err)
+ }
+
+ fc := &FileConfig{}
+ fc.Browser.Proxy = BrowserProxyConfig{
+ Server: "",
+ Username: "bob",
+ Password: "hunter2",
+ BypassList: []string{"*.internal"},
+ }
+ if err := SaveFileConfig(fc, path); err != nil {
+ t.Fatal(err)
+ }
+
+ raw, err := os.ReadFile(path)
+ if err != nil {
+ t.Fatal(err)
+ }
+ var onDisk struct {
+ Browser struct {
+ Proxy struct {
+ Server *string `json:"server"`
+ Username string `json:"username"`
+ } `json:"proxy"`
+ } `json:"browser"`
+ }
+ if err := json.Unmarshal(raw, &onDisk); err != nil {
+ t.Fatal(err)
+ }
+ if onDisk.Browser.Proxy.Server == nil {
+ t.Fatalf("the cleared server is absent from the file, so the save could not tell it apart from an unmodelled key and left the old one: %s", raw)
+ }
+ if *onDisk.Browser.Proxy.Server != "" {
+ t.Errorf("browser.proxy.server = %q after being cleared, want empty — a proxy that cannot be turned off is fail-open: %s", *onDisk.Browser.Proxy.Server, raw)
+ }
+ if onDisk.Browser.Proxy.Username != "bob" {
+ t.Errorf("clearing the server discarded the credentials (username = %q); they are meant to survive for the next server", onDisk.Browser.Proxy.Username)
+ }
+}
+
+// The render that makes the above possible, and its negative: a block with nothing in
+// it must not grow a server key.
+func TestOnlyANonEmptyProxyRendersAClearedServer(t *testing.T) {
+ withCredentials, err := json.Marshal(BrowserProxyConfig{Username: "bob"})
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !strings.Contains(string(withCredentials), `"server":""`) {
+ t.Errorf("a serverless block renders as %s, without the server key the save needs to clear it", withCredentials)
+ }
+
+ empty, err := json.Marshal(BrowserProxyConfig{})
+ if err != nil {
+ t.Fatal(err)
+ }
+ if strings.Contains(string(empty), "server") {
+ t.Errorf("an empty proxy block renders as %s, growing a key nobody set", empty)
+ }
+}
+
+// The negative control this fix must not break: a genuinely empty proxy block stays
+// absent from the file rather than being written as an empty object.
+func TestAnEmptyProxyBlockIsStillOmitted(t *testing.T) {
+ fc := &FileConfig{}
+ fc.Browser.Proxy = BrowserProxyConfig{}
+
+ raw, err := json.Marshal(fc)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if strings.Contains(string(raw), `"proxy"`) {
+ t.Errorf("an empty proxy block was written to the file: %s", raw)
+ }
+}
+
+// AC2: an incomplete proxy is REPORTED, not dropped and not refused. The report has to
+// arrive as an advisory rather than a validation error: validation errors gate
+// `config set` behind a confirm that answers no off a TTY, so gating this one would
+// refuse the very write that completes the block.
+func TestAServerlessProxyBlockIsReportedAsAnAdvisory(t *testing.T) {
+ fc := &FileConfig{}
+ fc.Browser.Proxy = BrowserProxyConfig{Username: "bob", Password: "hunter2"}
+
+ advisories := FileConfigAdvisories(fc)
+
+ found := ""
+ for _, advisory := range advisories {
+ if strings.Contains(advisory, "browser.proxy") {
+ found = advisory
+ }
+ }
+ if found == "" {
+ t.Fatalf("a proxy with credentials and no server is reported nowhere; advisories = %v", advisories)
+ }
+ if !strings.Contains(found, "browser.proxy.server") {
+ t.Errorf("the advisory %q does not name browser.proxy.server as the prerequisite, so the reader is not told which key to set", found)
+ }
+
+ for _, err := range ValidateFileConfig(fc) {
+ if strings.Contains(err.Error(), "browser.proxy.server") {
+ t.Errorf("the missing server is ALSO a gating validation error (%v); off a TTY that refuses the write that would complete the block", err)
+ }
+ }
+}
+
+// AC3: the end state is what matters — setting the server afterwards clears the report
+// and the proxy works with the credentials that were set first.
+func TestSettingTheServerAfterwardsCompletesThePreviouslySetProxy(t *testing.T) {
+ fc := &FileConfig{}
+ fc.Browser.Proxy = BrowserProxyConfig{Username: "bob", Password: "hunter2"}
+ fc.Browser.Proxy.Server = "http://proxy.example:8080"
+
+ for _, advisory := range FileConfigAdvisories(fc) {
+ if strings.Contains(advisory, "browser.proxy") {
+ t.Errorf("the incomplete-proxy advisory survives a server being set: %q", advisory)
+ }
+ }
+
+ flags, err := BrowserProxyFlags(fc.Browser.Proxy)
+ if err != nil {
+ t.Fatalf("BrowserProxyFlags after completing the block: %v", err)
+ }
+ if len(flags) == 0 || !strings.Contains(flags[0], "http://proxy.example:8080") {
+ t.Errorf("flags = %v, want the configured proxy — preserving the credentials is pointless if the completed block does not launch", flags)
+ }
+}
+
+// An incomplete block must not launch or authenticate: the values are kept, not applied.
+func TestAServerlessProxyNeitherLaunchesNorAuthenticates(t *testing.T) {
+ p := BrowserProxyConfig{Username: "bob", Password: "hunter2", BypassList: []string{"*.internal"}}
+
+ flags, err := BrowserProxyFlags(p)
+ if err != nil {
+ t.Fatalf("a serverless proxy must be a no-op at launch, not an error: %v", err)
+ }
+ if len(flags) != 0 {
+ t.Errorf("flags = %v, want none: there is no server to route through", flags)
+ }
+}
+
+// AC5: the rest of proxy validation now runs for a serverless block. The empty bypass
+// pattern was silently skipped, because one predicate answered both "no proxy is
+// configured" and "this block is empty".
+func TestProxyValidationRunsForAServerlessBlock(t *testing.T) {
+ for _, tc := range []struct {
+ name string
+ proxy BrowserProxyConfig
+ want string
+ }{
+ {name: "empty bypass pattern", proxy: BrowserProxyConfig{BypassList: []string{""}}, want: "bypass pattern must not be empty"},
+ {name: "bypass pattern with a separator", proxy: BrowserProxyConfig{BypassList: []string{"a;b"}}, want: "must not contain whitespace"},
+ {name: "username without password", proxy: BrowserProxyConfig{Username: "bob"}, want: "password is required"},
+ {name: "password without username", proxy: BrowserProxyConfig{Password: "hunter2"}, want: "username is required"},
+ {name: "invalid geo", proxy: BrowserProxyConfig{Geo: &BrowserProxyGeoConfig{CountryISO: "ITALY"}}, want: "geo"},
+ } {
+ t.Run(tc.name, func(t *testing.T) {
+ errs := ValidateBrowserProxy("browser.proxy", tc.proxy)
+
+ joined := ""
+ for _, err := range errs {
+ joined += err.Error() + "\n"
+ }
+ if !strings.Contains(joined, tc.want) {
+ t.Errorf("a serverless block skipped its own validation: errors = %q, want one containing %q", joined, tc.want)
+ }
+ for _, err := range errs {
+ if strings.Contains(err.Error(), "proxy server is empty") {
+ t.Errorf("the absent server is reported as a malformed one (%v); that is the advisory's job, and as an error it would gate the completing write", err)
+ }
+ }
+ })
+ }
+}
+
+// The negative control for the validator's entry gate: nothing set means nothing to
+// validate, which is today's behaviour and must not change.
+func TestAnEmptyProxyBlockIsStillValidatedAsAbsent(t *testing.T) {
+ if errs := ValidateBrowserProxy("browser.proxy", BrowserProxyConfig{}); len(errs) != 0 {
+ t.Errorf("an empty proxy block produced %v, want no diagnostics at all", errs)
+ }
+ fc := &FileConfig{}
+ for _, advisory := range FileConfigAdvisories(fc) {
+ if strings.Contains(advisory, "proxy") {
+ t.Errorf("an empty proxy block was reported as incomplete: %q", advisory)
+ }
+ }
+}
diff --git a/internal/config/browser_targets.go b/internal/config/browser_targets.go
index 50faeb11..8bd71908 100644
--- a/internal/config/browser_targets.go
+++ b/internal/config/browser_targets.go
@@ -71,14 +71,7 @@ func ValidateBrowserTargets(bc BrowserConfig) []error {
var errs []error
- // Stable iteration order so error output is deterministic.
- names := make([]string, 0, len(bc.Targets))
- for name := range bc.Targets {
- names = append(names, name)
- }
- sort.Strings(names)
-
- for _, name := range names {
+ for _, name := range SortedBrowserTargetNames(bc.Targets) {
t := bc.Targets[name]
if !IsValidBrowserTargetName(name) {
errs = append(errs, ValidationError{
@@ -193,6 +186,17 @@ func validateTargetExtraFlags(targetName, raw string) []error {
// migrateLegacyBrowserConfig synthesizes targets["default"] from legacy fields when targets is empty.
// When both blocks are present, explicit targets win and conflict=true so the caller can warn.
+// SortedBrowserTargetNames walks the targets in a stable order, so diagnostics naming
+// several of them read the same way on every run.
+func SortedBrowserTargetNames(targets BrowserTargetsConfig) []string {
+ names := make([]string, 0, len(targets))
+ for name := range targets {
+ names = append(names, name)
+ }
+ sort.Strings(names)
+ return names
+}
+
func migrateLegacyBrowserConfig(bc *BrowserConfig, browsersDefault string) (synthesized bool, conflict bool) {
if bc == nil {
return false, false
@@ -417,7 +421,10 @@ func applyTargetToRuntime(out *RuntimeConfig, t BrowserTargetConfig) {
out.BrowserExtraFlags = t.ExtraFlags
}
out.Cloak = mergeCloakConfig(out.Cloak, t.Cloak)
- if !t.Proxy.IsZero() {
+ // HasNoServer, not IsZero: this replaces the inherited proxy wholesale, so a target
+ // block carrying only credentials must not clear a working parent proxy and send
+ // traffic out directly. Such a block is reported by ProxyServerRequiredAdvisory.
+ if !t.Proxy.HasNoServer() {
out.Proxy = cloneBrowserProxyConfig(t.Proxy)
}
}
diff --git a/internal/config/config_apply_census_test.go b/internal/config/config_apply_census_test.go
index 3b54341c..a8d7a675 100644
--- a/internal/config/config_apply_census_test.go
+++ b/internal/config/config_apply_census_test.go
@@ -33,15 +33,7 @@ var refusedRatherThanCarried = map[string]refusedKey{
// acceptedAndDropped holds the keys `config set` still takes and the value in effect never
// reflects. Each is a filed defect, not a licence: the entry names the mechanism and the
// card that owns it, and the census reds again the moment one of them starts working.
-var acceptedAndDropped = map[string]string{
- "browser.proxy.username": "PIN-178: a proxy block with no server counts as absent, so the save drops it",
- "browser.proxy.password": "PIN-178: a proxy block with no server counts as absent, so the save drops it",
- "browser.proxy.bypassList": "PIN-178: a proxy block with no server counts as absent, so the save drops it",
- "browser.proxy.geo.timezone": "PIN-178: a proxy block with no server counts as absent, so the save drops it",
- "browser.proxy.geo.locale": "PIN-178: a proxy block with no server counts as absent, so the save drops it",
- "browser.proxy.geo.webrtcIP": "PIN-178: a proxy block with no server counts as absent, so the save drops it",
- "browser.proxy.geo.countryISO": "PIN-178: a proxy block with no server counts as absent, so the save drops it",
-}
+var acceptedAndDropped = map[string]string{}
// censusValueFor holds the values the generic candidate list cannot guess: a key whose
// setter or loader takes only a fixed vocabulary needs a member of it, or the census would
diff --git a/internal/config/config_file_marshal.go b/internal/config/config_file_marshal.go
index 448a09d1..18185ded 100644
--- a/internal/config/config_file_marshal.go
+++ b/internal/config/config_file_marshal.go
@@ -55,7 +55,9 @@ func cloakBrowserConfigJSONFromFile(c CloakBrowserConfig) *cloakBrowserConfigJSO
}
}
-// browserProxyJSONFromFile returns nil when proxy is disabled so omitempty drops the field.
+// browserProxyJSONFromFile returns nil only when NOTHING is set, so omitempty drops the
+// field. It used to drop the whole block whenever server was unset, which discarded
+// credentials, bypass list and geo that `config set` had just reported as saved.
func browserProxyJSONFromFile(p BrowserProxyConfig) *BrowserProxyConfig {
if p.IsZero() {
return nil
diff --git a/internal/config/config_methods.go b/internal/config/config_methods.go
index 70079022..fdfede9a 100644
--- a/internal/config/config_methods.go
+++ b/internal/config/config_methods.go
@@ -1,6 +1,9 @@
package config
-import "path/filepath"
+import (
+ "fmt"
+ "path/filepath"
+)
// EnabledSensitiveEndpoints returns the names of sensitive endpoint families
// that are currently enabled in the runtime configuration.
@@ -74,3 +77,19 @@ const ActivityStateDirRefusal = "observability.activity.stateDir is not settable
// and the wording it replaces ("remove the key") named an action no shipped command
// performs, while riding a diagnostic that aborted every later config write off a TTY.
const ActivityStateDirAdvisory = "observability.activity.stateDir is ignored: " + activityStateDirReason
+
+// ProxyServerRequiredAdvisory reports a proxy block that carries credentials, a bypass
+// list or geo overrides but no server: the values are kept and PinchTab uses none of
+// them, because with no server there is no proxy. It takes the block's own path so the
+// key it tells the reader to set is the one that block actually needs — browser.proxy
+// and each browser.targets.<name>.proxy have their own.
+//
+// An ADVISORY and not a validation error, deliberately, and the reason is the path
+// rather than the severity: validation errors gate `config set` through a confirm that
+// answers no off a TTY, so making this one gate would refuse the very write that
+// completes the block — `config set browser.proxy.username` would abort for every agent
+// and pipe, which is the failure the advisory tier was introduced to end. Unlike the
+// other advisory here there IS an action, so this one names it.
+func ProxyServerRequiredAdvisory(field string) string {
+ return fmt.Sprintf("%s has no server, so nothing it holds is used: set %s.server to a scheme://host:port to make it take effect", field, field)
+}
diff --git a/internal/config/validate.go b/internal/config/validate.go
index a648cb52..dedc1c03 100644
--- a/internal/config/validate.go
+++ b/internal/config/validate.go
@@ -670,5 +670,24 @@ func FileConfigAdvisories(fc *FileConfig) []string {
if strings.TrimSpace(fc.Observability.Activity.StateDir) != "" {
advisories = append(advisories, ActivityStateDirAdvisory)
}
+ advisories = append(advisories, proxyServerAdvisories(fc)...)
+ return advisories
+}
+
+// proxyServerAdvisories reports every proxy block that holds something but no server.
+// Target proxies are walked too: their blocks were never dropped at save, so a
+// serverless one has always been kept and silently unused — the same state this card's
+// defect produced for browser.proxy, one level down.
+func proxyServerAdvisories(fc *FileConfig) []string {
+ var advisories []string
+ if !fc.Browser.Proxy.IsZero() && fc.Browser.Proxy.HasNoServer() {
+ advisories = append(advisories, ProxyServerRequiredAdvisory("browser.proxy"))
+ }
+ for _, name := range SortedBrowserTargetNames(fc.Browser.Targets) {
+ target := fc.Browser.Targets[name]
+ if !target.Proxy.IsZero() && target.Proxy.HasNoServer() {
+ advisories = append(advisories, ProxyServerRequiredAdvisory(fmt.Sprintf("browser.targets.%s.proxy", name)))
+ }
+ }
return advisories
}