{"evidenceTier":"self-signed","executor":{"implName":"manual-demand-test","implVersion":"1","mode":"manual","model":"claude-sonnet-5 (solve), reviewed"},"generatedAt":"2026-07-28T12:01:11.284Z","participant":{"agentEoa":"0x654862876C8Ddaa048Fa9E0D32D5e0e81bD4Bd20"},"payload":{"branch":"fix/len-truncate-large-values-1801","commitSha":"deebfa36e6","patchDiff":"From deebfa36e6912d7bcd56a522f3d029a28a7745e6 Mon Sep 17 00:00:00 2001\nFrom: Oaksprout <oaksproutthetan@gmail.com>\nDate: Tue, 28 Jul 2026 12:58:25 +0100\nSubject: [PATCH] assert: reduce truncatingFormat limit for readable failure\n output\n\ntruncatingFormat's limit was sized (~32KB) purely to keep a formatted\nvalue from making the assembled failure message exceed the\nbufio.MaxScanTokenSize line-length limit go test's output scanner\nimposes, which was enough to stop failure output being dropped\nentirely (#1525) but still let a single assertion swamp the console\nwith tens of kilobytes of unreadable output.\n\nAs suggested by @brackendawson on #1801, reduce the limit\nsignificantly instead of special-casing Len: 4000 bytes, matching the\ndefault MaxLength used by Gomega's format package for the same\npurpose, while staying comfortably below bufio.MaxScanTokenSize so\nthe original guarantee still holds. Anyone who needs the untruncated\nvalue can print it with t.Logf.\n\nThis affects every assertion that shares truncatingFormat (Equal,\nEqualValues, EqualExportedValues, NotEqual, NotEqualValues, Nil,\nEmpty, Len, Contains, NotContains, Subset, NotSubset, Same, NotSame,\nNoError, EqualError, ErrorContains, ErrorIs, NotErrorIs, ErrorAs,\nNotErrorAs, Zero), which is the intended scope per the issue thread.\nElementsMatch is out of scope: it does not use truncatingFormat.\n\nFixes #1801\n---\n assert/assertions.go      | 22 ++++++++++++++++++----\n assert/assertions_test.go | 22 ++++++++++++++++++++--\n 2 files changed, 38 insertions(+), 6 deletions(-)\n\ndiff --git a/assert/assertions.go b/assert/assertions.go\nindex 1419e47..78139b4 100644\n--- a/assert/assertions.go\n+++ b/assert/assertions.go\n@@ -614,14 +614,28 @@ func formatUnequalValues(expected, actual interface{}) (e string, a string) {\n \treturn truncatingFormat(\"%#v\", expected), truncatingFormat(\"%#v\", actual)\n }\n \n+// maxMessageSize is the maximum length, in bytes, of a single formatted\n+// value that truncatingFormat will print before appending \"<... truncated>\".\n+//\n+// This used to be derived from bufio.MaxScanTokenSize, sized just small\n+// enough that two truncated values plus their surrounding sentence couldn't\n+// exceed the line-length limit go test's output scanner imposes; that\n+// avoided losing failure output entirely (#1525), but a limit of ~32KB per\n+// value still let a single assertion swamp the console with output no one\n+// can read (#1801). 4000 keeps failure output readable, matches the default\n+// MaxLength used by Gomega's format package (github.com/onsi/gomega/format)\n+// for the same purpose, and remains comfortably below bufio.MaxScanTokenSize\n+// so the original line-length guarantee still holds. Anyone who needs the\n+// untruncated value can print it themselves, e.g. via t.Logf.\n+const maxMessageSize = 4000\n+\n // truncatingFormat formats the data and truncates it if it's too long.\n //\n-// This helps keep formatted error messages lines from exceeding the\n-// bufio.MaxScanTokenSize max line length that the go testing framework imposes.\n+// This helps keep formatted error messages readable and ensures they don't\n+// exceed the bufio.MaxScanTokenSize max line length that the go testing\n+// framework imposes.\n func truncatingFormat(format string, data interface{}) string {\n \tvalue := fmt.Sprintf(format, data)\n-\t// Give us space for two truncated objects and the surrounding sentence.\n-\tmaxMessageSize := bufio.MaxScanTokenSize/2 - 100\n \tif len(value) > maxMessageSize {\n \t\tvalue = value[0:maxMessageSize] + \"<... truncated>\"\n \t}\ndiff --git a/assert/assertions_test.go b/assert/assertions_test.go\nindex 11642e0..f9b45f0 100644\n--- a/assert/assertions_test.go\n+++ b/assert/assertions_test.go\n@@ -1,7 +1,6 @@\n package assert\n \n import (\n-\t\"bufio\"\n \t\"bytes\"\n \t\"encoding/json\"\n \t\"errors\"\n@@ -3653,7 +3652,7 @@ func Test_validateEqualArgs(t *testing.T) {\n func Test_truncatingFormat(t *testing.T) {\n \tt.Parallel()\n \n-\toriginal := strings.Repeat(\"a\", bufio.MaxScanTokenSize/2-102)\n+\toriginal := strings.Repeat(\"a\", maxMessageSize-2)\n \tresult := truncatingFormat(\"%#v\", original)\n \tEqual(t, fmt.Sprintf(\"%#v\", original), result, \"string should not be truncated\")\n \n@@ -3981,6 +3980,25 @@ func TestLenWithSliceTooLongToPrint(t *testing.T) {\n \tContains(t, mockT.errorString(), `<... truncated>\" should have 1 item(s), but has 1000000`)\n }\n \n+// TestLenWithSliceTooLongToPrintIsReadable is a regression test for\n+// https://github.com/stretchr/testify/issues/1801. Truncating the printed\n+// value at all (TestLenWithSliceTooLongToPrint above) is not enough on its\n+// own: the pre-#1801 limit still let a single assertion dump tens of\n+// kilobytes into the console, which is just as unreadable as no output at\n+// all. The failure message must be truncated to a size a human can actually\n+// read in a terminal.\n+func TestLenWithSliceTooLongToPrintIsReadable(t *testing.T) {\n+\tt.Parallel()\n+\tmockT := new(mockTestingT)\n+\tlongSlice := make([]int, 1_000_000)\n+\tLen(mockT, longSlice, 1)\n+\terrStr := mockT.errorString()\n+\tContains(t, errStr, \"<... truncated>\")\n+\tif len(errStr) > 8000 {\n+\t\tt.Errorf(\"Len failure message on a very large slice is %d bytes, want a readable size (<=8000 bytes):\\n%s\", len(errStr), errStr)\n+\t}\n+}\n+\n func TestContainsWithSliceTooLongToPrint(t *testing.T) {\n \tt.Parallel()\n \tmockT := new(mockTestingT)\n-- \n2.50.1 (Apple Git-155)\n\n","testEvidence":"8/8 packages pass with -race in golang:1.26 container; TDD regression fails on base (32755 bytes) passes with fix; maintainer-directed approach, 4000-byte limit grounded in Gomega precedent"},"role":"solution","schemaVersion":"jinn.execution.v1","signature":{"algo":"secp256k1","hash":"0x5286139c52f3d7ced3e19f96c7eed6ff7ee0636431604cd8c9fece38b7c9e3ad","sig":"0xe551928ee9fb624458e2a051a15755a8bea4374bf3baef5080dbffdf63acb9125984316fe5e79a40615b5643a7c3f108be78903106c7be8edf0a598b4befbac600","signer":"0x654862876C8Ddaa048Fa9E0D32D5e0e81bD4Bd20"},"solverType":"external-repo-fix.manual.v1","task":{"baseCommit":"001eb7946baf451879253643e4ce4b38eaa0d4a7","cid":"bafkreif2z2soxg5de2qfkt6r47xlpang3cgzbqnlp6fof7trugmmu7old4","onchainCreationTx":"0xa76fba7592b040a1e56bf911143cacf7ab869b045a54316302126f1d0a21c067","repo":"stretchr/testify","requestId":"0x390e8d3aa8d1a6643f9afa919232c746f9edf062c86500acda935e334660f7a9"}}