GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — File upload to Storage fails silently · Issue #1712 · googleapis/google-cloud-python

File upload to Storage fails silently #1712

New issue
Copy link
New issue
Copy link
Closed
Closed
File upload to Storage fails silently#1712
Copy link
Assignees
tseaver
Labels
api: storageIssues related to the Cloud Storage API.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Description

@liorsbg
liorsbg
opened on Apr 11, 2016
Issue body actions

Hello, I'm trying to upload a file to Storage from a Compute instance.
Following the example in the docs:

from gcloud import storage
client = storage.Client()
bucket = client.get_bucket('my-bucket-name')
blob = bucket.blob('my-test-file.txt')
blob.upload_from_string('this is test content!')

Nothing happens. No error message, no file created/uploaded in the bucket, blob.exists() returns False.

I don't think it's an access control/permissions thing as the bucket has default settings and I'm able to modify existing blobs.

Any leads on how to debug this?

Also, I think it would make sense to throw an exception or give some sort of indication/explanation that it failed.

Reacted by orkenstein, Paul Fitzgerald, Catherine19950122 and Miguel Carvalho

Activity

  1. dhermes
    added
    api: storageIssues related to the Cloud Storage API.
    on Apr 11, 2016
  2. dhermes commented on Apr 11, 2016

    @dhermes
    dhermes
    on Apr 11, 2016
    Contributor
    More actions

    It should fail with an exception if the upload failed. The blob.exists() being False may be due to eventual consistency.

  3. tseaver commented on Apr 11, 2016

    @tseaver
    tseaver
    on Apr 11, 2016
    Contributor
    More actions

    Thanks for the report! I'm guessing that bucket.exists() returns False: if so, then you need to call bucket.create() before blob.upload_from_string(). I was able to reproduce your report that way: the error is that the 404 from the back-end (due to the non-existent bucket) is being dropped on the floor.

  4. tseaver
    added
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    on Apr 11, 2016
  5. tseaver commented on Apr 11, 2016

    @tseaver
    tseaver
    on Apr 11, 2016
    Contributor
    More actions
    > /home/tseaver/projects/agendaless/Google/src/gcloud-python/gcloud/streaming/http_wrapper.py(355)_make_api_request_no_retry()
    -> if info is None:
    (Pdb) pp info
    {'alt-svc': 'quic=":443"; ma=2592000; v="32,31,30,29,28,27,26,25"',
     'alternate-protocol': '443:quic',
     'content-length': '165',
     'content-type': 'application/json; charset=UTF-8',
     'date': 'Mon, 11 Apr 2016 18:55:56 GMT',
     'server': 'UploadServer',
     'status': '404',
     'vary': 'Origin, X-Origin',
     'x-guploader-uploadid': 'AEnB2UqUUnsXbGr_B5UC4iut3KXc-TKQUbER1ffezwzKXKatM5ZRBetpJfJM90_-9p7yVZNK747V9Nm0ypPTIdy9U83mh8BUfg'}
    (Pdb) pp content
    '{\n "error": {\n  "errors": [\n   {\n    "domain": "global",\n    "reason": "notFound",\n    "message": "Not Found"\n   }\n  ],\n  "code": 404,\n  "message": "Not Found"\n }\n}\n'
  6. liorsbg commented on Apr 11, 2016

    @liorsbg
    liorsbg
    on Apr 11, 2016
    Author
    More actions

    Thanks for the quick reply!
    @dhermes file doesn't show up ever, checked on the web viewer as well.
    @tseaver bucket.exists() returns True.
    On an existing file in the same bucket, everything works as expected (make_public, delete, etc...)

  7. tseaver commented on Apr 11, 2016

    @tseaver
    tseaver
    on Apr 11, 2016
    Contributor
    More actions

    We do have a bug that the upload code drops 40x errors (other than 429 "Too Many Requests") on the floor.

  8. dhermes commented on Apr 11, 2016

    @dhermes
    dhermes
    on Apr 11, 2016
    Contributor
    More actions

    Blerg! Thanks for finding that @tseaver. @craigcitro Any idea why that snippet exists? @tseaver Link to bug?

  9. tseaver commented on Apr 11, 2016

    @tseaver
    tseaver
    on Apr 11, 2016
    Contributor
    More actions

    This is that bug. )

  10. dhermes commented on Apr 11, 2016

    @dhermes
    dhermes
    on Apr 11, 2016
    Contributor
    More actions

    Ha gotcha.

  11. tseaver commented on Apr 11, 2016

    @tseaver
    tseaver
    on Apr 11, 2016
    Contributor
    More actions

    @craigcitro the issue goes back to the original apitools codebase. I don't know why 40x response codes would be skipped.

  12. craigcitro commented on Apr 11, 2016

    @craigcitro
    craigcitro
    on Apr 11, 2016
    Contributor
    More actions

    @thobrla for the error question -- Travis, do you remember this offhand? (If not, I'll take a look soon.)

  13. thobrla commented on Apr 11, 2016

    @thobrla
    thobrla
    on Apr 11, 2016
    More actions

    I think the default CheckResponse function in http_wrapper only intends to process retryable errors. Non-retryable errors like 400, 403, 404, etc. are returned to the client who can interpret them depending on the application logic.

  14. dhermes commented on Apr 11, 2016

    @dhermes
    dhermes
    on Apr 11, 2016
    Contributor
    More actions

    Thanks @thobrla!

  15. tseaver commented on Apr 11, 2016

    @tseaver
    tseaver
    on Apr 11, 2016
    Contributor
    More actions

    Just guessing: is there a notion that a 404 is a "retriable" error in a general case? I can see how it would be for some cases (e.g., DELETE on a resource 404s due to eventual consistency), but that can't be a good overall rule. In general, 40x errors are "user errors", and should just be raised.

    • 400 Bad Request (raise)
    • 401 Unauthorized (raise)
    • 403 Forbidden (raise)
    • 404 Not Found (raise unless app policy says retry after backoff)
    • 405 Method Not Allowed (raise)
    • 406 Not Acceptable (raise)
    • 408 Request Timeout (retriable after backoff?)
    • 409 Conflict (maybe retriable after backoff?)
    • 410 Gone (raise)
    • 411 Length Required (raise)
    • 412 Precondition Failed (raise)
    • 413 Request Entity Too Large (raise)
    • 414 Request-URI Too Long (raise)
    • 415 Unsupported Media Type (raise)
    • 416 Requested Range Not Satisfiable (raise unless app policy says retry after backoff)
    • 417 Expectation Failed (raise)

    The 50x "Server Error" codes are also a mixed bag:

    • 500 Internal Server Error (maybe retriable after backoff?)
    • 501 Not Implemented (raise)
    • 502 Bad Gateway (retriable after backoff)
    • 503 Service Unavailable (retriable after backoff)
    • 504 Gateway Timeout (retriable after backoff)
    • 505 HTTP Version Not Supported (raise)
  16. craigcitro commented on Apr 11, 2016

    @craigcitro
    craigcitro
    on Apr 11, 2016
    Contributor
    More actions

    @tseaver Just to confirm -- apitools does not retry the 4xx requests, but we do retry the 5xx ones. The only exception should be 429, basically because some services use that as a retryable code.

    Are you seeing something different?

  17. thobrla commented on Apr 11, 2016

    @thobrla
    thobrla
    on Apr 11, 2016
    More actions

    Outside of 429, all of the 400's would only be retriable in very application-specific scenarios. So I think sending the response to the client is appropriate.

    500 is retriable after backoff.

    I agree that 501/505 are unlikely to succeed with retries. Right we aren't bitten by that because the services simply don't return those error codes (and we're using supported HTTP versions).

  18. tseaver commented on Apr 11, 2016

    @tseaver
    tseaver
    on Apr 11, 2016
    Contributor
    More actions

    @craigcitro nope: somehow the knowledge of that didn't transfer, and so we were dropping the errors on the floor. #1717 adds code to the caller of our (forked) apitools to handle error responses.

  19. tseaver
    closed this as completedin #1717on Apr 18, 2016
  20. dhermes commented on Apr 18, 2016

    @dhermes
    dhermes
    on Apr 18, 2016
    Contributor
    More actions

    @tseaver Have you been able to verify that this fixes the issue here? I tried it and can't get the original snippet to fail (get_bucket() would fail if the bucket didn't exist, and the upload would never occur).

  21. tseaver commented on Apr 18, 2016

    @tseaver
    tseaver
    on Apr 18, 2016
    Contributor
    More actions

    @dhermes I was never able to reproduce with an already-existing bucket. I did verify that the code now raises a NotFound:

    >>> from gcloud.storage import Client
    >>> client = Client()
    >>> bucket = client.bucket('1712-tseaver-no-such-bucket')
    >>> bucket.exists()
    False
    >>> blob = bucket.blob('my-blob-name')
    >>> blob.upload_from_string('this is test content!')
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "gcloud/storage/blob.py", line 548, in upload_from_string
        client=client)
      File "gcloud/storage/blob.py", line 469, in upload_from_file
        self._check_response_error(request, http_response)
      File "gcloud/storage/blob.py", line 359, in _check_response_error
        error_info=request.url)
    gcloud.exceptions.NotFound: 404 Not Found (https://www.googleapis.com/upload/storage/v1/b/1712-tseaver-no-such-bucket/o?uploadType=media&name=my-blob-name)
  22. dhermes commented on Apr 18, 2016

    @dhermes
    dhermes
    on Apr 18, 2016
    Contributor
    More actions

    I confirmed as well. Thanks for the snippet.

  23. JustinBeckwith
    assigned
    tseaver
    on Feb 1, 2021
  24. parthea
    added a commit that references this issue on Nov 24, 2025

    build: include error information when integration test fails (#1712)

    79a1680
  25. parthea
    added 3 commits that reference this issue on Mar 6, 2026

    chore: update docfx minimum Python version (#1712)

    a1f577f

    feat(grpc_user_agent): send `user_agent` to grpc channel (#1712)

    c03a1d9

    chore: librarian release pull request: 20260202T123858Z (#1736)

    aac3fd4
  26. parthea
    added a commit that references this issue on Apr 1, 2026

    docs: move multimodal notebook out of experimental folder (#1712)

    b01142d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @tseaver
    tseaver

Labels

api: storageIssues related to the Cloud Storage API.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.