Skip to content

Reading document did not exhaust input buffer #534

Closed
@felipsmartins

Description

@felipsmartins

Description

While I know this is not a bug/issue at all, I couldn't to understand the reason this exception:

PHP Fatal error: Uncaught exception 'MongoDB\Driver\Exception\UnexpectedValueException' with message 'Reading document did not exhaust input buffer' in /home/martins/www/projects/cadunico-agent/main.php:69
Stack trace:
#0 /home/martins/www/projects/cadunico-agent/main.php(69): MongoDB\BSON\toJSON('\xDE\x00\x00\x00\x07_id\x00X\x17\x81\xE4"9...')
#1 {main}
thrown in /home/martins/www/projects/cadunico-agent/main.php on line 69

Fatal error: Uncaught exception 'MongoDB\Driver\Exception\UnexpectedValueException' with message 'Reading document did not exhaust input buffer' in /home/martins/www/projects/cadunico-agent/main.php on line 69

MongoDB\Driver\Exception\UnexpectedValueException: Reading document did not exhaust input buffer in /home/martins/www/projects/cadunico-agent/main.php on line 69

BSON files from mongodump:

selecao_108

Note reading non large files like 307bytes it going okay. But reading bson files bigger than 2 kbytes the above exception is throwed.

Environment

$ php -i | grep -E 'mongodb|libmongoc|libbson'

/etc/php5/cli/conf.d/20-mongodb.ini,
mongodb
libbson bundled version => 1.5.4
libmongoc bundled version => 1.5.4
libmongoc SSL => enabled
libmongoc SSL library => OpenSSL
libmongoc crypto => enabled
libmongoc crypto library => libcrypto
libmongoc crypto system profile => disabled
libmongoc SASL => enabled
mongodb.debug => no value => no value
PATH => /opt/mongodb/3.0/bin:/home/martins/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/martins/.config/composer/vendor/bin:/opt/java/bin:/opt/anaconda/bin
_SERVER["PATH"] => /opt/mongodb/3.0/bin:/home/martins/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/martins/.config/composer/vendor/bin:/opt/java/bin:/opt/anaconda/bin

Test Script

If possible, attach a complete PHP script that can be excuted on its own to
reproduce the issue. Clarify whether this script can be run from the CLI or if
it can only be reproduced through a web SAPI.

<?php
$bsonFilename = '/path/to/mongodump/my_collection.bson';
$binaryContent = file_get_contents($bsonFilename);
$extendedJson = MongoDB\BSON\toJSON($binaryContent);

Well, there's any limitation for reading bson files via mongodb-php-driver? It's supposed to read only non-large bson files? If so what is the max bson file size?

I've attached bson files in this current issue.
Also, reading the exactly same bson files via bsondump works well.

Thanks in advance!

BSON-files.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions