René's URL Explorer Experiment


Title: `LargeFileUploadTask.upload()` throws a 400 error when file size is smaller than max_chunk_size · Issue #718 · microsoftgraph/msgraph-sdk-python-core · GitHub

Open Graph Title: `LargeFileUploadTask.upload()` throws a 400 error when file size is smaller than max_chunk_size · Issue #718 · microsoftgraph/msgraph-sdk-python-core

X Title: `LargeFileUploadTask.upload()` throws a 400 error when file size is smaller than max_chunk_size · Issue #718 · microsoftgraph/msgraph-sdk-python-core

Description: Describe the bug While uploading a large file using LargeFileUploadTask to a SharePoint drive location, if the overall file size is less than the max_chunk_size defined (e.g uploading a 5 KB file but the chunk size is 10 MB), the async L...

Open Graph Description: Describe the bug While uploading a large file using LargeFileUploadTask to a SharePoint drive location, if the overall file size is less than the max_chunk_size defined (e.g uploading a 5 KB file b...

X Description: Describe the bug While uploading a large file using LargeFileUploadTask to a SharePoint drive location, if the overall file size is less than the max_chunk_size defined (e.g uploading a 5 KB file b...

Opengraph URL: https://github.com/microsoftgraph/msgraph-sdk-python-core/issues/718

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`LargeFileUploadTask.upload()` throws a 400 error when file size is smaller than max_chunk_size","articleBody":"### Describe the bug\r\n\r\nWhile uploading a large file using `LargeFileUploadTask` to a SharePoint drive location, if the overall file size is less than the max_chunk_size defined (e.g uploading a  5 KB file but the chunk size is 10 MB), the async `LargeFileUploadTask.upload()` method uploads the file but throws below error:\r\n\r\n```\r\nAPIError:\r\n        APIError\r\n        Code: 400\r\n        message: The server returned an unexpected status code and no error class is registered for this code 400\r\n```\r\n\r\n### Expected behavior\r\n\r\nThe upload task should complete without any errors OR the error message should be meaningful e.g. File is too small.\r\n\r\n### How to reproduce\r\n\r\n```python\r\ndestination_path = \"path/to/your_file.txt\" # path on SharePoint drive where I want to upload the file\r\nfile_path = \"path/to/your_file.txt\" # A small file like 10 KB in my local system\r\n\r\nasync def upload_large_file(graph_client, drive_id):\r\n    try:\r\n        file = open(file_path, 'rb')\r\n        uploadable_properties = DriveItemUploadableProperties(\r\n            additional_data={'@microsoft.graph.conflictBehavior': 'replace'}\r\n        )\r\n        upload_session_request_body = CreateUploadSessionPostRequestBody(item=uploadable_properties)\r\n        print(f\"Uploadable Properties: {uploadable_properties.additional_data}\")\r\n        # can be used for normal drive uploads\r\n        try:\r\n            upload_session = await graph_client.drives.by_drive_id(\r\n                drive_id\r\n            ).items.by_drive_item_id(\"root:/my_docs/test_upload.txt:\"\r\n                                     ).create_upload_session.post(upload_session_request_body)\r\n            \r\n        except APIError as ex:\r\n            print(f\"Error creating upload session: {ex}\")\r\n\r\n        # to be used for large file uploads\r\n        large_file_upload_session = LargeFileUploadSession(\r\n            upload_url=upload_session.upload_url,\r\n            expiration_date_time=datetime.now() + timedelta(days=1),\r\n            additional_data=upload_session.additional_data,\r\n            is_cancelled=False,\r\n            next_expected_ranges=upload_session.next_expected_ranges\r\n        )\r\n\r\n        max_chunk_size = 10 * 1024 * 1024\r\n        task = LargeFileUploadTask(\r\n            upload_session=large_file_upload_session, \r\n            request_adapter=graph_client.request_adapter, \r\n            stream=file, \r\n            parsable_factory=DriveItem, \r\n            max_chunk_size=max_chunk_size\r\n        )\r\n        total_length = os.path.getsize(file_path)\r\n        \r\n        # Upload the file\r\n        # The callback\r\n        def progress_callback(uploaded_byte_range: tuple[int, int]):\r\n            print(f\"Uploaded {uploaded_byte_range[0]} bytes of {total_length} bytes\\n\\n\")\r\n\r\n        try:\r\n            upload_result = await task.upload(progress_callback)\r\n            print(f\"Upload complete {upload_result}\")\r\n        except APIError as ex:\r\n            print(f\"Error uploading: {ex.message} - {ex.response_status_code}\")\r\n            raise\r\n    except APIError as e:\r\n        print(f\"Error: {e}\")\r\n        raise\r\n\r\nasyncio.run(upload_large_file(graph_client, drive_id))\r\n```\r\n\r\n### SDK Version\r\n\r\n1.1.7\r\n\r\n### Latest version known to work for scenario above?\r\n\r\n_No response_\r\n\r\n### Known Workarounds\r\n\r\nChanging the max_chunk_size value to (file_size - 1) seems to prevent the error from occurring.\r\n\r\n### Debug output\r\n\r\n\u003cdetails\u003e\u003csummary\u003eClick to expand log\u003c/summary\u003e\r\n```\r\n\r\n\u003cLog output here\u003e\r\n\r\n```\r\n\u003c/details\u003e\r\n\r\n\r\n### Configuration\r\n\r\nOS: Windows 10\r\nArchitecture: x64\r\nPython version: 3.9.19\r\n\r\n### Other information\r\n\r\n_No response_","author":{"url":"https://github.com/itsmariodias","@type":"Person","name":"itsmariodias"},"datePublished":"2024-11-23T07:31:29.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/718/msgraph-sdk-python-core/issues/718"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:6ec604cf-3ea2-8331-ee26-6af48bece657
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idC3BA:66035:C6662:10D577:6969D26B
html-safe-nonce004687f8a77b30f3ca29eb3f7643baf5268de25f51e00552706a4797a4e53eb4
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDM0JBOjY2MDM1OkM2NjYyOjEwRDU3Nzo2OTY5RDI2QiIsInZpc2l0b3JfaWQiOiI3MjcyMDE2ODkxMDc5MTUyMjM1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac74668e0771d97e5b3f527c959e1a55e3854b25ee82430468e6298921f6a35f11
hovercard-subject-tagissue:2685595682
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoftgraph/msgraph-sdk-python-core/718/issue_layout
twitter:imagehttps://opengraph.githubassets.com/45f518317bfeb1fd0c8610ea80855e2c983825fa9b077128e926586c7273f5bd/microsoftgraph/msgraph-sdk-python-core/issues/718
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/45f518317bfeb1fd0c8610ea80855e2c983825fa9b077128e926586c7273f5bd/microsoftgraph/msgraph-sdk-python-core/issues/718
og:image:altDescribe the bug While uploading a large file using LargeFileUploadTask to a SharePoint drive location, if the overall file size is less than the max_chunk_size defined (e.g uploading a 5 KB file b...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameitsmariodias
hostnamegithub.com
expected-hostnamegithub.com
Noneacedec8b5f975d9e3d494ddd8f949b0b8a0de59d393901e26f73df9dcba80056
turbo-cache-controlno-preview
go-importgithub.com/microsoftgraph/msgraph-sdk-python-core git https://github.com/microsoftgraph/msgraph-sdk-python-core.git
octolytics-dimension-user_id17304259
octolytics-dimension-user_loginmicrosoftgraph
octolytics-dimension-repository_id242847794
octolytics-dimension-repository_nwomicrosoftgraph/msgraph-sdk-python-core
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id242847794
octolytics-dimension-repository_network_root_nwomicrosoftgraph/msgraph-sdk-python-core
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release83c08c21cdda978090dc44364b71aa5bc6dcea79
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/microsoftgraph/msgraph-sdk-python-core/issues/718#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoftgraph%2Fmsgraph-sdk-python-core%2Fissues%2F718
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoftgraph%2Fmsgraph-sdk-python-core%2Fissues%2F718
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=microsoftgraph%2Fmsgraph-sdk-python-core
Reloadhttps://github.com/microsoftgraph/msgraph-sdk-python-core/issues/718
Reloadhttps://github.com/microsoftgraph/msgraph-sdk-python-core/issues/718
Reloadhttps://github.com/microsoftgraph/msgraph-sdk-python-core/issues/718
microsoftgraph https://github.com/microsoftgraph
msgraph-sdk-python-corehttps://github.com/microsoftgraph/msgraph-sdk-python-core
Notifications https://github.com/login?return_to=%2Fmicrosoftgraph%2Fmsgraph-sdk-python-core
Fork 45 https://github.com/login?return_to=%2Fmicrosoftgraph%2Fmsgraph-sdk-python-core
Star 277 https://github.com/login?return_to=%2Fmicrosoftgraph%2Fmsgraph-sdk-python-core
Code https://github.com/microsoftgraph/msgraph-sdk-python-core
Issues 15 https://github.com/microsoftgraph/msgraph-sdk-python-core/issues
Pull requests 16 https://github.com/microsoftgraph/msgraph-sdk-python-core/pulls
Discussions https://github.com/microsoftgraph/msgraph-sdk-python-core/discussions
Actions https://github.com/microsoftgraph/msgraph-sdk-python-core/actions
Projects 0 https://github.com/microsoftgraph/msgraph-sdk-python-core/projects
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/microsoftgraph/msgraph-sdk-python-core/security
Please reload this pagehttps://github.com/microsoftgraph/msgraph-sdk-python-core/issues/718
Insights https://github.com/microsoftgraph/msgraph-sdk-python-core/pulse
Code https://github.com/microsoftgraph/msgraph-sdk-python-core
Issues https://github.com/microsoftgraph/msgraph-sdk-python-core/issues
Pull requests https://github.com/microsoftgraph/msgraph-sdk-python-core/pulls
Discussions https://github.com/microsoftgraph/msgraph-sdk-python-core/discussions
Actions https://github.com/microsoftgraph/msgraph-sdk-python-core/actions
Projects https://github.com/microsoftgraph/msgraph-sdk-python-core/projects
Security https://github.com/microsoftgraph/msgraph-sdk-python-core/security
Insights https://github.com/microsoftgraph/msgraph-sdk-python-core/pulse
New issuehttps://github.com/login?return_to=https://github.com/microsoftgraph/msgraph-sdk-python-core/issues/718
New issuehttps://github.com/login?return_to=https://github.com/microsoftgraph/msgraph-sdk-python-core/issues/718
LargeFileUploadTask.upload() throws a 400 error when file size is smaller than max_chunk_sizehttps://github.com/microsoftgraph/msgraph-sdk-python-core/issues/718#top
P1Priorityhttps://github.com/microsoftgraph/msgraph-sdk-python-core/issues?q=state%3Aopen%20label%3A%22P1%22
area:uploadsFocused on functional modules of the producthttps://github.com/microsoftgraph/msgraph-sdk-python-core/issues?q=state%3Aopen%20label%3A%22area%3Auploads%22
priority:p1High priority/Major issue but not blocking or Big percentage of customers affected.Bug SLA <=7dayshttps://github.com/microsoftgraph/msgraph-sdk-python-core/issues?q=state%3Aopen%20label%3A%22priority%3Ap1%22
type:bugA broken experiencehttps://github.com/microsoftgraph/msgraph-sdk-python-core/issues?q=state%3Aopen%20label%3A%22type%3Abug%22
https://github.com/itsmariodias
https://github.com/itsmariodias
itsmariodiashttps://github.com/itsmariodias
on Nov 23, 2024https://github.com/microsoftgraph/msgraph-sdk-python-core/issues/718#issue-2685595682
P1Priorityhttps://github.com/microsoftgraph/msgraph-sdk-python-core/issues?q=state%3Aopen%20label%3A%22P1%22
area:uploadsFocused on functional modules of the producthttps://github.com/microsoftgraph/msgraph-sdk-python-core/issues?q=state%3Aopen%20label%3A%22area%3Auploads%22
priority:p1High priority/Major issue but not blocking or Big percentage of customers affected.Bug SLA <=7dayshttps://github.com/microsoftgraph/msgraph-sdk-python-core/issues?q=state%3Aopen%20label%3A%22priority%3Ap1%22
type:bugA broken experiencehttps://github.com/microsoftgraph/msgraph-sdk-python-core/issues?q=state%3Aopen%20label%3A%22type%3Abug%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.