{"record":{"id":"a495648711fa37da","repo":"bazelbuild/bazel","slug":"s-n","errorCode":null,"errorMessage":"%s\\n","messagePattern":"%s\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/tools/remote/src/main/cpp/testonly_output_service/bazel_output_service_impl.cc","lineNumber":121,"sourceCode":"\nint RunServer(int argc, char** argv) {\n  int exit_code = 0;\n  TemporaryMemory scratch = BeginScratch(0);\n  ParsedCommandLine* command_line = ParseCommandLine(scratch.arena, argc, argv);\n  if (IsEmptyStr8(command_line->error)) {\n    BazelOutputServiceImpl service;\n\n    Str8 address = PushStr8F(scratch.arena, \"0.0.0.0:%d\", command_line->port);\n    grpc::ServerBuilder builder;\n    builder.AddListeningPort((char*)address.ptr,\n                             grpc::InsecureServerCredentials());\n    builder.RegisterService(&service);\n    std::unique_ptr<grpc::Server> server = builder.BuildAndStart();\n    fprintf(stderr, \"Server listening on port %d...\\n\", command_line->port);\n\n    server->Wait();\n  } else {\n    fprintf(stderr, \"%s\\n\", command_line->error.ptr);\n    exit_code = 1;\n  }\n  EndScratch(scratch);\n  return exit_code;\n}\n","sourceCodeStart":103,"sourceCodeEnd":127,"githubUrl":"https://github.com/bazelbuild/bazel/blob/e6e199d0601a244511b4cf18c8b2828aa73db1fd/src/tools/remote/src/main/cpp/testonly_output_service/bazel_output_service_impl.cc#L103-L127","documentation":"This is the error branch of the test-only output service binary used by Bazel's remote execution tests: it parses its own command line into a scratch arena, and when parsing fails (command_line->error set) it prints that error string followed by a newline to stderr and sets exit_code = 1. The %s\\n wrapper is just the emitter; the actual reason is in the parsed error text.","triggerScenarios":"Launching bazel_output_service_impl with an unknown flag, a flag missing its value (--port without a number), or a malformed port argument; the parser fills command_line->error and this branch prints it.","commonSituations":"Running Bazel's remote-execution integration tests with a stale test binary expecting different flags; developers experimenting with the output service by hand and guessing options.","solutions":["Read the line printed just before exit: it names the exact flag that failed to parse.","Check the tool's flag definitions (its ParseCommandLine) and pass only supported flags, e.g. --port=<n>.","If triggered inside Bazel's own tests, sync the test-only binary and the test expectations to the same commit.","Pass --help (if defined) or read the source's option table for the accepted set."],"exampleFix":"# before: bazel_output_service_impl --listen 8080   (unknown flag)\n# after:  bazel_output_service_impl --port 8080","handlingStrategy":"validation","validationCode":"// validate the port flag before starting the service\nif (argc != 3 || strcmp(argv[1], \"--port\") != 0 ||\n    atoi(argv[2]) <= 0 || atoi(argv[2]) > 65535) {\n  fprintf(stderr, \"usage: bazel_output_service_impl --port <1-65535>\\n\");\n  return 1;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass only flags the tool's parser knows (see its ParseCommandLine).","Keep test binaries and test expectations from the same commit in Bazel's repo.","Read the error line printed before exit — it names the offending flag."],"tags":["c","remote-execution","test-only","cli","argument-parsing","grpc"],"backgroundTag":null,"analyzedSha":"e6e199d0601a244511b4cf18c8b2828aa73db1fd","analyzedAt":"2026-08-14T10:24:27.848Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}