{"record":{"id":"d6f6e527106dbd15","repo":"sqshq/sampler","slug":"errortext-string","errorCode":null,"errorMessage":"errorText.String()","messagePattern":"errorText\\.String\\(\\)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"data/int_basic.go","lineNumber":120,"sourceCode":"\n\tvar resultText strings.Builder\n\tvar errorText strings.Builder\n\n\tfor {\n\t\tselect {\n\t\tcase stdout := <-s.stdoutCh:\n\t\t\tif len(stdout) > 0 {\n\t\t\t\tresultText.WriteString(stdout)\n\t\t\t\tresultText.WriteString(\"\\n\")\n\t\t\t}\n\t\tcase stderr := <-s.stderrCh:\n\t\t\tif len(stderr) > 0 {\n\t\t\t\terrorText.WriteString(stderr)\n\t\t\t\terrorText.WriteString(\"\\n\")\n\t\t\t}\n\t\tcase <-timeout:\n\t\t\tif errorText.Len() > 0 {\n\t\t\t\treturn \"\", errors.New(errorText.String())\n\t\t\t}\n\t\t\treturn s.item.transform(vtclean.Clean(resultText.String(), false))\n\t\t}\n\t}\n}\n","sourceCodeStart":102,"sourceCodeEnd":126,"githubUrl":"https://github.com/sqshq/sampler/blob/9bc7ba732d31f32a917ad4b5605f00b76ebe0891/data/int_basic.go#L102-L126","documentation":"In the basic (non-PTY) interactive shell's execute loop, when the command's timeout fires while stderr output has been accumulated, the shell returns all collected stderr text as a Go error instead of the cleaned stdout. This means the error message you see is literally the command's own stderr, prefixed only by the call-site wrapper (if any). The library throws this so timeouts surface the program's own diagnostics rather than silently dropping them.","triggerScenarios":"Running a command through a basic interactive shell whose runtime exceeds s.timeout while stderr bytes were already collected via errorText; the <-timeout case fires and returns errors.New(errorText.String()).","commonSituations":"Long-running commands (slow network installs, builds) under a tight per-item timeout config; commands that print warnings to stderr early then hang; Windows/macOS environments where the command blocks on a prompt.","solutions":["Increase the shell timeout (Item configuration) so the command finishes before the timer fires","Fix the underlying command so it does not write to stderr or hang (check the stderr text in the error for the real cause)","Reduce or eliminate stderr noise from the command (redirect benign warnings) if stderr presence plus slow run is expected","Use PTY mode where supported for better interactive handling, or run the command outside the interactive shell with an explicit timeout wrapper"],"exampleFix":"// before\nitem := item.NewItem(...)\nitem.Interactive.Type = \"basic\"\n// after (give slow command more time)\nitem.Interactive.Shell.Timeout = 60 * time.Second","handlingStrategy":"try-catch","validationCode":"if cmd timeout risk: pre-estimate runtime, e.g. dry-run once with a generous timeout before enabling in config","typeGuard":null,"tryCatchPattern":"out, err := shell.execute()\nif err != nil {\n    log.Printf(\"command timed out or wrote to stderr: %v\", err)\n    // fall back to last known good value or skip sample\n    return lastValue, nil\n}","preventionTips":["Set realistic per-item timeouts based on measured command runtime","Minimize stderr noise in invoked commands","Alert on timeout errors so chronically slow commands are fixed"],"tags":["go","timeout","stderr","interactive-shell"],"backgroundTag":"request-timeout","analyzedSha":"9bc7ba732d31f32a917ad4b5605f00b76ebe0891","analyzedAt":"2026-09-06T08:38:02.595Z","contentChangedAt":"2026-09-06T08:38:02.595Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}