Skip to content

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

fix: the reported solver identity is a literal beside a Name() that reads the constant (PIN-078)

Luigi Agosti51591a7abddf
diff --git a/internal/autosolver/external/capsolver.go b/internal/autosolver/external/capsolver.go
index eec577e5..cd16ce9b 100644
--- a/internal/autosolver/external/capsolver.go
+++ b/internal/autosolver/external/capsolver.go
@@ -67,7 +67,7 @@ func (c *Capsolver) CanHandle(ctx context.Context, page autosolver.Page) (bool,
// (create task → poll result → inject token) must be filled in
// with the Capsolver API v1 protocol.
func (c *Capsolver) Solve(ctx context.Context, page autosolver.Page, executor autosolver.ActionExecutor) (*autosolver.Result, error) {
- result := &autosolver.Result{SolverUsed: "capsolver"}
+ result := &autosolver.Result{SolverUsed: autosolver.CapsolverSolverName}
if c.config.APIKey == "" {
result.Error = "capsolver API key not configured"
diff --git a/internal/autosolver/external/external_test.go b/internal/autosolver/external/external_test.go
new file mode 100644
index 00000000..24217e6e
--- /dev/null
+++ b/internal/autosolver/external/external_test.go
@@ -0,0 +1,36 @@
+package external
+
+import (
+ "context"
+ "testing"
+
+ "github.com/pinchtab/pinchtab/internal/autosolver"
+)
+
+// The reported solver identity has to be the registered one. Both were spelled as
+// literals beside a Name() that already read the constant, so renaming the constant
+// changed what registers while leaving what the Result reports — and nothing in the
+// tree noticed. These solvers are skeletons today, which is why it stayed latent
+// rather than shipping a wrong name; it is also why it would have survived until
+// the first real implementation.
+func TestSolverUsedMatchesTheRegisteredName(t *testing.T) {
+ for _, solver := range []autosolver.Solver{
+ NewCapsolver(CapsolverConfig{}),
+ NewTwoCaptcha(TwoCaptchaConfig{}),
+ } {
+ t.Run(solver.Name(), func(t *testing.T) {
+ // An unset API key is the earliest return, and it is enough: the
+ // Result is built before the check.
+ result, err := solver.Solve(context.Background(), nil, nil)
+ if err == nil {
+ t.Fatal("expected the unset-API-key error, so this test exercises the real Solve path")
+ }
+ if result == nil {
+ t.Fatal("Solve returned no Result to check")
+ }
+ if result.SolverUsed != solver.Name() {
+ t.Errorf("Result.SolverUsed = %q but Name() = %q — the reported solver identity has drifted from the registered one", result.SolverUsed, solver.Name())
+ }
+ })
+ }
+}
diff --git a/internal/autosolver/external/twocaptcha.go b/internal/autosolver/external/twocaptcha.go
index 6fac30cd..20d14cef 100644
--- a/internal/autosolver/external/twocaptcha.go
+++ b/internal/autosolver/external/twocaptcha.go
@@ -63,7 +63,7 @@ func (t *TwoCaptcha) CanHandle(ctx context.Context, page autosolver.Page) (bool,
// This is a skeleton implementation. The actual HTTP client logic
// (submit → poll → inject) must be filled in with the 2Captcha API protocol.
func (t *TwoCaptcha) Solve(ctx context.Context, page autosolver.Page, executor autosolver.ActionExecutor) (*autosolver.Result, error) {
- result := &autosolver.Result{SolverUsed: "twocaptcha"}
+ result := &autosolver.Result{SolverUsed: autosolver.TwoCaptchaSolverName}
if t.config.APIKey == "" {
result.Error = "2captcha API key not configured"