bug: mergeOptions always overwrites ShowBrowser regardless of intent #16

Closed
opened 2026-02-14 16:06:49 +00:00 by Claude · 3 comments
Collaborator

Parent: #3

Description

In browser_init.go:128-158, mergeOptions() treats ShowBrowser differently from all other boolean fields:

func mergeOptions(base BrowserOptions, opts []BrowserOptions) BrowserOptions {
    for _, o := range opts {
        // ...
        if o.RequireServer {
            base.RequireServer = true  // only sets if true
        }
        if o.UseLocalOnly {
            base.UseLocalOnly = true   // only sets if true
        }
        base.ShowBrowser = o.ShowBrowser  // ALWAYS overwrites
    }
    return base
}

Unlike RequireServer and UseLocalOnly which only set to true, ShowBrowser is unconditionally overwritten. This means:

  • If you pass BrowserOptions{ShowBrowser: true} followed by BrowserOptions{UserAgent: "custom"}, the second option resets ShowBrowser to false even though it wasn't explicitly set.

Fix

Either:

  1. Treat ShowBrowser consistently with other booleans: if o.ShowBrowser { base.ShowBrowser = true }
  2. Or use a pointer *bool for all optional boolean fields to distinguish "not set" from "set to false"
**Parent:** #3 ## Description In `browser_init.go:128-158`, `mergeOptions()` treats `ShowBrowser` differently from all other boolean fields: ```go func mergeOptions(base BrowserOptions, opts []BrowserOptions) BrowserOptions { for _, o := range opts { // ... if o.RequireServer { base.RequireServer = true // only sets if true } if o.UseLocalOnly { base.UseLocalOnly = true // only sets if true } base.ShowBrowser = o.ShowBrowser // ALWAYS overwrites } return base } ``` Unlike `RequireServer` and `UseLocalOnly` which only set to `true`, `ShowBrowser` is unconditionally overwritten. This means: - If you pass `BrowserOptions{ShowBrowser: true}` followed by `BrowserOptions{UserAgent: "custom"}`, the second option resets `ShowBrowser` to `false` even though it wasn't explicitly set. ## Fix Either: 1. Treat `ShowBrowser` consistently with other booleans: `if o.ShowBrowser { base.ShowBrowser = true }` 2. Or use a pointer `*bool` for all optional boolean fields to distinguish "not set" from "set to false"
Claude added the bugpriority/mediumtype/task labels 2026-02-14 16:07:34 +00:00
Author
Collaborator

Starting work on this as part of PR 7 (also includes #15). Will change ShowBrowser to *bool so nil means "don't override" in mergeOptions().

Starting work on this as part of PR 7 (also includes #15). Will change `ShowBrowser` to `*bool` so nil means "don't override" in `mergeOptions()`.
Author
Collaborator

Work finished. PR: #38 (merged)

Changed ShowBrowser to *bool with extractor.Bool() helper. Nil now means "don't override" in mergeOptions().

Work finished. PR: #38 (merged) Changed `ShowBrowser` to `*bool` with `extractor.Bool()` helper. Nil now means "don't override" in `mergeOptions()`.
Author
Collaborator

Resolved by PR #38ShowBrowser changed to *bool in BrowserOptions so nil means "don't override". Browser defaults also aligned to Firefox.

Resolved by PR #38 — `ShowBrowser` changed to `*bool` in `BrowserOptions` so `nil` means "don't override". Browser defaults also aligned to Firefox.
Sign in to join this conversation.