bazelbuild/bazel · error

%s\n

Error message

%s\n

What it means

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.

Source

Thrown at src/tools/remote/src/main/cpp/testonly_output_service/bazel_output_service_impl.cc:121

int RunServer(int argc, char** argv) {
  int exit_code = 0;
  TemporaryMemory scratch = BeginScratch(0);
  ParsedCommandLine* command_line = ParseCommandLine(scratch.arena, argc, argv);
  if (IsEmptyStr8(command_line->error)) {
    BazelOutputServiceImpl service;

    Str8 address = PushStr8F(scratch.arena, "0.0.0.0:%d", command_line->port);
    grpc::ServerBuilder builder;
    builder.AddListeningPort((char*)address.ptr,
                             grpc::InsecureServerCredentials());
    builder.RegisterService(&service);
    std::unique_ptr<grpc::Server> server = builder.BuildAndStart();
    fprintf(stderr, "Server listening on port %d...\n", command_line->port);

    server->Wait();
  } else {
    fprintf(stderr, "%s\n", command_line->error.ptr);
    exit_code = 1;
  }
  EndScratch(scratch);
  return exit_code;
}

View on GitHub (pinned to e6e199d060)

Solutions

  1. Read the line printed just before exit: it names the exact flag that failed to parse.
  2. Check the tool's flag definitions (its ParseCommandLine) and pass only supported flags, e.g. --port=<n>.
  3. If triggered inside Bazel's own tests, sync the test-only binary and the test expectations to the same commit.
  4. Pass --help (if defined) or read the source's option table for the accepted set.

Example fix

# before: bazel_output_service_impl --listen 8080   (unknown flag)
# after:  bazel_output_service_impl --port 8080
Defensive patterns

Strategy: validation

Validate before calling

// validate the port flag before starting the service
if (argc != 3 || strcmp(argv[1], "--port") != 0 ||
    atoi(argv[2]) <= 0 || atoi(argv[2]) > 65535) {
  fprintf(stderr, "usage: bazel_output_service_impl --port <1-65535>\n");
  return 1;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of bazelbuild/bazel@e6e199d060 (2026-08-14). Data as JSON: /api/errors/a495648711fa37da. Report an issue: GitHub.