mongoc_client_get_database_names does not set the bson_error_t struct or return NULL even if an error is encountered.
If I change mongoc-client.c:1316 to:
if (!ret && !mongoc_cursor_error(cursor, error)) {
then it looks like the error is set.
A simple test case is connecting with an invalid user/pwd, then calling mongoc_client_get_database_names (should return NULL).