{"record":{"id":"e869d50be696f1bb","repo":"t8y2/dbx","slug":"agent-did-not-become-ready-v","errorCode":null,"errorMessage":"agent did not become ready: %v","messagePattern":"agent did not become ready: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/rabbitmq/bench/agent_compare.go","lineNumber":324,"sourceCode":"\tstdin, err := process.command.StdinPipe()\n\tif err != nil {\n\t\treturn nil, 0, err\n\t}\n\tstdout, err := process.command.StdoutPipe()\n\tif err != nil {\n\t\treturn nil, 0, err\n\t}\n\tprocess.command.Stderr = os.Stderr\n\tprocess.stdin = stdin\n\tprocess.reader = bufio.NewScanner(stdout)\n\tprocess.reader.Buffer(make([]byte, 64*1024), 512*1024*1024)\n\tstart := time.Now()\n\tif err := process.command.Start(); err != nil {\n\t\treturn nil, 0, err\n\t}\n\tif !process.reader.Scan() {\n\t\tprocess.kill()\n\t\treturn nil, 0, fmt.Errorf(\"agent did not become ready: %v\", process.reader.Err())\n\t}\n\tif !strings.Contains(process.reader.Text(), `\"ready\":true`) {\n\t\tprocess.kill()\n\t\treturn nil, 0, fmt.Errorf(\"agent did not become ready: %s\", process.reader.Text())\n\t}\n\treturn process, time.Since(start), nil\n}\n\nfunc (process *agentProcess) call(method string, params map[string]any) (json.RawMessage, error) {\n\tprocess.nextID++\n\trequest := map[string]any{\n\t\t\"jsonrpc\": \"2.0\",\n\t\t\"id\":      process.nextID,\n\t\t\"method\":  method,\n\t\t\"params\":  params,\n\t}\n\tpayload, err := json.Marshal(request)\n\tif err != nil {","sourceCodeStart":306,"sourceCodeEnd":342,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/rabbitmq/bench/agent_compare.go#L306-L342","documentation":"startAgent launches the agent and waits for its first stdout line as a readiness signal. If the bufio scanner fails (Scan returns false), the process is killed and this error wraps the scanner's Err, meaning stdout closed/errored before a readiness line was produced.","triggerScenarios":"The agent process exits immediately (bad flags, missing config, unhandled panic) or its stdout closes before printing the ready line, so reader.Scan() returns false and reader.Err() is non-nil (or io.EOF with no line).","commonSituations":"Agent binary built for wrong platform; agent panics at boot due to missing RabbitMQ DSN env var; agent writes its ready line to stderr instead of stdout.","solutions":["Read the wrapped reader.Err() and run the agent manually to see its startup output","Confirm the agent prints {\"ready\":true,...} to stdout as its first line","Fix missing/invalid startup configuration (env vars, config file) that crashes the agent","Rebuild the agent binary for the current OS/arch"],"exampleFix":"// agent main: ensure readiness is written to stdout first\nfmt.Println(`{\"ready\":true}`)\n// before any heavy work that can fail\n// after\nif err := initBroker(); err != nil { fmt.Fprintln(os.Stderr, err); os.Exit(1) }\nfmt.Println(`{\"ready\":true}`)","handlingStrategy":"validation","validationCode":"out, err := exec.Command(agent.Command, \"--selfcheck\").CombinedOutput()\nif err != nil {\n    return fmt.Errorf(\"agent %q fails selfcheck: %v: %s\", agent.Command, err, out)\n}","typeGuard":null,"tryCatchPattern":"process, _, err := startAgent(agent.Command)\nif err != nil && strings.Contains(err.Error(), \"agent did not become ready\") {\n    log.Fatalf(\"agent startup failed, check stderr/config: %v\", err)\n}","preventionTips":["Ensure the agent prints its readiness JSON to stdout as the very first line","Route all agent logging to stderr","Validate required env vars/config at agent boot before signaling anything"],"tags":["subprocess","readiness","startup-failure"],"backgroundTag":"subprocess-failed-to-start","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}