Skip to content

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

test: the wrong-type message names the type but nothing pins the remedy, and the helper's comment still describes callers that moved off it (PIN-242)

Luigi Agosti13ef0dddfb6d
diff --git a/internal/mcp/handlers_helpers.go b/internal/mcp/handlers_helpers.go
index a9ac4317..33477ba1 100644
--- a/internal/mcp/handlers_helpers.go
+++ b/internal/mcp/handlers_helpers.go
@@ -64,20 +64,19 @@ func firstNonEmptyString(r mcp.CallToolRequest, keys ...string) string {
return ""
}
-// firstSuppliedString answers "was this argument sent", for the one argument whose
-// empty string MEANS something: a fill clears the field. That is the same question
-// the bridge asks — ActionRequest.HasText is inferred from key presence over the same
-// text/value pair — and it is the question firstNonEmptyString cannot answer, since
-// collapsing empty and absent is its entire job.
+// firstSuppliedString answers "was this argument sent", the question firstNonEmptyString
+// cannot answer because collapsing empty and absent is its entire job. It is the same
+// question the bridge asks — ActionRequest.HasText is inferred from key presence over the
+// same text/value pair that fill and select both read.
//
-// The value travels verbatim rather than trimmed, so MCP fill and POST /action fill
-// agree on every input and not merely on the clear case.
+// The value travels verbatim rather than trimmed, so MCP and POST /action agree on every
+// input and not merely on the cases where emptiness is the point.
+//
+// The dialog arguments keep the collapsing helper deliberately: an empty dialogAction means
+// not-specified, so a value this helper would report as supplied-but-unusable is instead a
+// skipped one-shot handler. That is a silent SKIP rather than a misleading refusal — a
+// different shape, and it wants its own decision rather than being swept in here.
//
-// Every other caller keeps the collapsing helper deliberately: typing nothing is
-// meaningless, and for select and the dialog arguments the BRIDGE itself collapses
-// empty with absent (actionSelect refuses an empty value; DialogText is a plain
-// string with no presence flag), so reading presence here would promise a
-// distinction the request cannot carry.
// wrongType names the JSON type of a value that WAS supplied under one of the keys but is
// not a string. The library does not enforce the declared type before calling a handler, so
// a model answering a numeric-looking field with 2024 rather than "2024" arrives here — and
diff --git a/internal/mcp/handlers_interaction_test.go b/internal/mcp/handlers_interaction_test.go
index 10c272cb..98efa072 100644
--- a/internal/mcp/handlers_interaction_test.go
+++ b/internal/mcp/handlers_interaction_test.go
@@ -638,13 +638,30 @@ func TestFillNamesAWrongTypedValueInsteadOfCallingItMissing(t *testing.T) {
if !res.IsError {
t.Fatalf("accepted %v", tc.args)
}
- if text := resultText(t, res); !strings.Contains(text, tc.wantSays) {
+ text := resultText(t, res)
+ if !strings.Contains(text, tc.wantSays) {
t.Errorf("error = %q, want it to say %q so the caller knows what to change", text, tc.wantSays)
}
+ assertNamesTheRemedy(t, text, tc.wantSays)
})
}
}
+// Naming the type is only half the repair: a caller told its number is not a string, with no
+// hint that quoting fixes it, still has no next move — which was the dead end being removed.
+// The rows that need the remedy are derived from the type clause rather than listed again, so
+// a new wrong-type row cannot be added without it.
+func assertNamesTheRemedy(t *testing.T, message, wantSays string) {
+ t.Helper()
+
+ if !strings.Contains(wantSays, "must be a string") {
+ return
+ }
+ if !strings.Contains(message, "quote it") {
+ t.Errorf("error = %q names the type but not the remedy, so the caller learns what is wrong and not what to send", message)
+ }
+}
+
// The clear idiom must keep working, since distinguishing a wrong type from an absent one
// must not re-refuse the empty string this tool was fixed to accept.
func TestFillStillSendsAnEmptyStringVerbatim(t *testing.T) {
@@ -737,9 +754,11 @@ func TestSelectAndTypeNameAWrongTypedArgumentInsteadOfCallingItMissing(t *testin
if !res.IsError {
t.Fatalf("accepted %v", tc.args)
}
- if text := resultText(t, res); !strings.Contains(text, tc.wantSays) {
+ text := resultText(t, res)
+ if !strings.Contains(text, tc.wantSays) {
t.Errorf("error = %q, want it to say %q so the caller knows what to change", text, tc.wantSays)
}
+ assertNamesTheRemedy(t, text, tc.wantSays)
})
}
}