Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-1969

Driver aborts after "mongoc_cluster_run_command_internal(): precondition failed: command_name"

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.6.0
    • Affects Version/s: None
    • Component/s: libmongoc
    • None

      To illustrate the case, it is sufficient to pass an empty BSON as a command to mongoc_client_command_simple():

      src/mongoc/mongoc-cluster.c:183 mongoc_cluster_run_command_internal(): precondition failed: command_name
      Aborted
      

      When something is appended to the command, the issue is gone. See the example below:

      #include <stdio.h>
      #include <mongoc.h>
      
      int main() {
      	mongoc_client_t *client;
      	bson_t command, reply;
      	bson_error_t error;
      	bool status;
      
      	mongoc_init();
      
      	client = mongoc_client_new("mongodb://127.0.0.1");
      	BSON_ASSERT(client);
      	bson_init(&command);
      	
      	// BSON_APPEND_BOOL(&command, "a", 1); // Issue is gone when uncommented
      
      	status = mongoc_client_command_simple(client, "test", &command, 0, &reply, &error);
      	if (!status) printf("Error: %s\n", error.message);
      
      	bson_destroy(&command);
      	bson_destroy(&reply);
      	mongoc_client_destroy(client);
      	mongoc_cleanup();
      	return 0;
      }
      

            Assignee:
            jesse@mongodb.com A. Jesse Jiryu Davis
            Reporter:
            neoxic Arseny Vakhrushev
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: