Unable to send large attachment: LargeFileUploadTask and headers

Open Beginner friendly
#1,794 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
php
Domain
api

Research direction

Start in Microsoft\Kiota\Abstractions\RequestHeaders and inspect the getAll method, especially its array_keys handling of header values. Reproduce or verify the large attachment upload path with PHP 8.4 and confirm that getAll returns string header keys and large attachments can be sent without the Guzzle request deprecation.

Written by the indexing model from the issue text.

Description

Unable to upload large attachment. In the file Microsoft\Kiota\Abstractions\RequestHeaders, the array_keys function is used, which casts a string to a number. PHP 8.4 on x64 does this.

In the getAll method, it is cast and then an error is returned: Since guzzlehttp/psr7 2.11: Passing int to GuzzleHttp\Psr7\Request::__construct() is deprecated; guzzlehttp/psr7 3.0 requires string|string[].

Instead of array_keys, you must use foreach.

A method with array_keys that casts string to int.

public function getAll(): array
{
    $result = [];
    foreach ($this->headers as $key => $value) {
        $result[$key] = array_keys($value);
    }
    return $result;
}

A method with foreach that works.

public function getAll(): array
{
    $result = [];
    foreach ($this->headers as $key => $value) {
        foreach ($value as $k => $v) {
            $result[$key][] = strval($k);
        }
        //$result[$key] = array_keys($value);
    }
    return $result;
}

After this change, sending large attachments works.

Dominant language
PHP
Stars
669
Forks
150
Avg merge
15h 21m
Merged PRs (30d)
3

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoftgraph/msgraph-sdk-php

All issues in microsoftgraph/msgraph-sdk-php

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.