You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by "chitralverma (via GitHub)" <gi...@apache.org> on 2025/06/13 07:46:32 UTC

[I] bug: issue with http service [opendal]

chitralverma opened a new issue, #6289:
URL: https://github.com/apache/opendal/issues/6289

   ### Describe the bug
   
   I'm trying to use the `http` service to read a remote xlsx file at a remote path and getting 0 content length on stat and 0 bytes on read.
   
   If i download this manually with wget and then read it from local fs, it works as expect.
   
   
   ### Steps to Reproduce
   
   source location: https://www.insee.fr/fr/statistiques/fichier/6051913/Nomenclature_N1_PCS2020.xlsx
   
   ```
   >>> import opendal
   >>> operator = opendal.Operator("http", endpoint="https://www.insee.fr")
   >>> 
   >>> operator.stat("/fr/statistiques/fichier/6051913/Nomenclature_N1_PCS2020.xlsx")
   Metadata(mode=file, content_length=0, content_type=application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, last_modified=None, etag=None)
   >>> 
   >>> operator.read("/fr/statistiques/fichier/6051913/Nomenclature_N1_PCS2020.xlsx")
   b''
   ```
   
   After downloading with wget
   ```
   wget https://www.insee.fr/fr/statistiques/fichier/6051913/Nomenclature_N1_PCS2020.xlsx
   ```
   
   ```
   >>>  
   >>> operator = opendal.Operator("fs", root="/")
   >>> operator.stat("/tmp/Nomenclature_N1_PCS2020.xlsx")
   Metadata(mode=file, content_length=6655, content_type=None, last_modified=2025-06-12T10:33:33, etag=None)
   >>> 
   >>> operator.read("/Users/chitralverma/Downloads/Nomenclature_N1_PCS2020.xlsx")
   b'PK\x03\x04\x14\x00\x08\x08\ .....
   ```
   
   
   ### Expected Behavior
   
   stat and read should return the correct results without the need to manually copy
   
   
   
   ### Additional Context
   
   
   wget output for your ref, which shows the correct content length
   ```
   wget https://www.insee.fr/fr/statistiques/fichier/6051913/Nomenclature_N1_PCS2020.xlsx
   --2025-06-13 13:00:10--  https://www.insee.fr/fr/statistiques/fichier/6051913/Nomenclature_N1_PCS2020.xlsx
   Resolving www.insee.fr (www.insee.fr)... 143.196.255.163, 194.254.37.163
   Connecting to www.insee.fr (www.insee.fr)|143.196.255.163|:443... connected.
   HTTP request sent, awaiting response... 200 
   Length: unspecified [application/vnd.openxmlformats-officedocument.spreadsheetml.sheet]
   Saving to: ‘Nomenclature_N1_PCS2020.xlsx.1’
   
   Nomenclature_N1_PCS2020.xlsx.1                           [ <=>                                                                                                                  ]   6.50K  --.-KB/s    in 0s      
   
   2025-06-13 13:00:11 (58.8 MB/s) - ‘Nomenclature_N1_PCS2020.xlsx.1’ saved [6655]
   ```
   
   ### Are you willing to submit a PR to fix this bug?
   
   - [ ] Yes, I would like to submit a PR.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] bug: issue with http service [opendal]

Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
dosubot[bot] commented on issue #6289:
URL: https://github.com/apache/opendal/issues/6289#issuecomment-2969414339

   <!-- Greeting -->
   Hi @chitralverma! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the opendal team.
   
   <!-- Answer -->
   This is a known limitation in OpenDAL's HTTP service: when the server omits the `Content-Length` header in response to a HEAD request (which is common for some servers and with chunked encoding), OpenDAL reports a content length of 0 in `stat`, and some clients may treat this as an empty file and not attempt to read it. The actual `read` operation uses GET and can stream the file even if the size is unknown, but the metadata is never updated with the real size after the fact. There is currently no fallback to probe the file size with a GET if the HEAD response is insufficient, unlike tools like wget or curl which are more robust in this scenario. This is not a recent regression but a longstanding design gap in OpenDAL's HTTP backend. Improving this would require changes to the stat logic to optionally use GET as a fallback when HEAD is incomplete, or to better indicate "unknown length" in metadata so clients still attempt reads. For now, a workaround is to download the file manual
 ly with wget or curl, as you've done, or to ensure your client attempts a read even if stat reports size 0.  
   [Reference](https://github.com/apache/opendal/blob/b3bc66b7d03096ce903addfc2f6defe08830ced7/core/src/services/http/backend.rs)
   
   
   <!-- Dosu Comment Footer -->
   *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).*
   
   ---
   <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/64a5e217-3c57-4b68-b447-3d258ffb6561?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/64a5e217-3c57-4b68-b447-3d258ffb6561?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/64a5e217-3c57-4b68-b447-3d258ffb6561?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/64a5e217-3c57-4b68-b447-3d258ffb6561?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/64a5e217-3c57-4b68-b447-3d258ffb6561?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/64a5e217-3c57-4b68-b447-3d258ffb6561?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/64a5e217-3c57-4b68-b447-3d258ffb6561?feedback_type=other)</sup>&nbsp;&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[!
 [Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/opendal/issues/6289)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] bug: issue with http service [opendal]

Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
dosubot[bot] commented on issue #6289:
URL: https://github.com/apache/opendal/issues/6289#issuecomment-2969444663

   <!-- Answer -->
   Right, the key detail here is that the server's response doesn't include a Content-Length header. OpenDAL's HTTP service relies on this header in the HEAD response to determine file size for stat; when it's missing, OpenDAL reports a size of 0, which can cause some clients (like the Python binding) to treat the file as empty and skip reading it. The actual file content is still available via GET, but OpenDAL doesn't update the metadata after reading, and there's currently no fallback to probe the size with GET if HEAD is incomplete. There aren't any alternative configurations or workarounds in OpenDAL itself for this—manual download or ensuring your client attempts a read even if stat reports size 0 are the only options for now. No ongoing discussions or issues are tracking a fix for this limitation.
   
   
   <!-- Dosu Comment Footer -->
   *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).*
   
   ---
   <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/d2997837-f8f5-478b-8ef8-c8f379e8f7ad?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/d2997837-f8f5-478b-8ef8-c8f379e8f7ad?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/d2997837-f8f5-478b-8ef8-c8f379e8f7ad?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/d2997837-f8f5-478b-8ef8-c8f379e8f7ad?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/d2997837-f8f5-478b-8ef8-c8f379e8f7ad?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/d2997837-f8f5-478b-8ef8-c8f379e8f7ad?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/d2997837-f8f5-478b-8ef8-c8f379e8f7ad?feedback_type=other)</sup>&nbsp;&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[!
 [Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/opendal/issues/6289)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] bug: issue with http service [opendal]

Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on issue #6289:
URL: https://github.com/apache/opendal/issues/6289#issuecomment-2969441217

   Hi, @chitralverma, @dosu is most right here.
   
   The header returned by this server is:
   
   ```shell
   :) curl -I https://www.insee.fr/fr/statistiques/fichier/6051913/Nomenclature_N1_PCS2020.xlsx
   HTTP/2 200
   date: Fri, 13 Jun 2025 07:52:54 GMT
   server: unknown
   permissions-policy: interest-cohort=()
   strict-transport-security: max-age=63072000
   vary: Origin,Access-Control-Request-Method,Access-Control-Request-Headers
   content-disposition: attachment; filename="Nomenclature_N1_PCS2020.xlsx"
   x-content-type-options: nosniff
   x-xss-protection: 1; mode=block
   cache-control: no-cache, no-store, max-age=0, must-revalidate
   pragma: no-cache
   expires: 0
   strict-transport-security: max-age=31536000 ; includeSubDomains
   x-frame-options: SAMEORIGIN
   via: 1.1 www.insee.fr
   referrer-policy: same-origin
   content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] bug: issue with http service [opendal]

Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo closed issue #6289: bug: issue with http service
URL: https://github.com/apache/opendal/issues/6289


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] bug: issue with http service [opendal]

Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on issue #6289:
URL: https://github.com/apache/opendal/issues/6289#issuecomment-2978972853

   Hi, I'm going to close this issue since we require the file to have content-length for now. Welcome to start new one if you have other ideas.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org