Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Table: batch operations fail with Header name can not be empty #191

Closed
spaze opened this issue Jul 17, 2019 · 1 comment
Closed

Table: batch operations fail with Header name can not be empty #191

spaze opened this issue Jul 17, 2019 · 1 comment
Assignees

Comments

@spaze
Copy link
Contributor

spaze commented Jul 17, 2019

Which service(blob, file, queue, table) does this issue concern?

Table

Which version of the SDK was used?

1.1.1, and master + dev branches

What problem was encountered?

Batch operations fail with "Header name can not be empty" exception, because guzzle/psr7 has added an empty header check in 1.6.0 which is failing now: guzzle/psr7#250 + guzzle/psr7#272

Steps to reproduce the issue?

  1. Clone the repo
  2. Install dependencies composer install
  3. Run the test with e.g.
AZURE_STORAGE_CONNECTION_STRING="UseDevelopmentStorage=true" vendor/bin/phpunit -c phpunit.xml.dist --filter BatchResultTest

The test will fail with

There was 1 error:

1) MicrosoftAzure\Storage\Tests\Unit\Table\Models\BatchResultTest::testCreate
InvalidArgumentException: Header name can not be empty.

/media/snafu-htdocs/private/libs/azure-storage-php/vendor/guzzlehttp/psr7/src/MessageTrait.php:210
/media/snafu-htdocs/private/libs/azure-storage-php/vendor/guzzlehttp/psr7/src/MessageTrait.php:146
/media/snafu-htdocs/private/libs/azure-storage-php/vendor/guzzlehttp/psr7/src/Response.php:106
/media/snafu-htdocs/private/libs/azure-storage-php/azure-storage-table/src/Table/Models/BatchResult.php:154
/media/snafu-htdocs/private/libs/azure-storage-php/tests/Unit/Table/Models/BatchResultTest.php:57

Have you found a mitigation/solution?

Yes. The issue is here

do {
$headerLine = $lines[$j++];
$headerTokens = explode(':', $headerLine);
$headers[trim($headerTokens[0])] =
isset($headerTokens[1]) ? trim($headerTokens[1]) : null;
} while (Resources::EMPTY_STRING != $headerLine);

The empty line which serves as a header/body delimiter in HTTP will be added to the headers array with null value before the do/while loop ends on Resources::EMPTY_STRING != $headerLine and then the psr7's assert will fail. I'll prepare a PR with a suggested fix (done: #192).

Do you run any sort of periodical tests/CI that would alert you to this issue as soon as possible?

@XiaoningLiu
Copy link
Member

XiaoningLiu commented Jul 18, 2019

Thanks for finding this. Enabling periodly ci sounds a good plan! We can enable periodical ci in Azure Pipeline.

https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants