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 — fix(storage): use OrderedDict while encoding POST policy by IlyaFaer · Pull Request #95 · googleapis/python-storage

This repository was archived by the owner on Mar 31, 2026. It is now read-only.

Conversation

@IlyaFaer

@IlyaFaer IlyaFaer commented Apr 1, 2020

Copy link
Copy Markdown

Towards #64 (comment)
Sometimes policy losses it's order while encoding into JSON. Adding OrderedDict() to fix this.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
IlyaFaer
use OrderedDict() while encoding POST policy
3265bb7
@IlyaFaer IlyaFaer added the api: storage Issues related to the googleapis/python-storage API. label Apr 1, 2020
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Apr 1, 2020
@IlyaFaer IlyaFaer changed the title use OrderedDict() while encoding POST policy fix(storage): use OrderedDict() while encoding POST policy Apr 1, 2020
IlyaFaer
IlyaFaer commented Apr 1, 2020
View reviewed changes
Comment thread google/cloud/storage/client.py
"expiration": policy_expires.isoformat() + "Z",
}.items()
)
),

@IlyaFaer IlyaFaer Apr 1, 2020

Copy link
Copy Markdown
Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expiration sometimes encoded before conditions - in such a cases tests are failing

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@frankyn frankyn Apr 1, 2020

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little concerned about imposing order in signing code given it's only used for conformance tests.

However, it doesn't change the outcome of expectation and will work as expected as a user.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread tests/unit/test_client.py
out_data = test_data["policyOutput"]

decoded_policy = base64.b64decode(fields["policy"]).decode("unicode_escape")
assert decoded_policy == out_data["expectedDecodedPolicy"]

@IlyaFaer IlyaFaer Apr 1, 2020

Copy link
Copy Markdown
Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved decoded_policy assert to the top: if something gone wrong in policy, it'll be easier to see it in decoded state - probably will save some time on debugging

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@IlyaFaer
IlyaFaer requested a review from frankyn April 1, 2020 20:27
@IlyaFaer
IlyaFaer marked this pull request as ready for review April 1, 2020 20:28
@IlyaFaer

IlyaFaer commented Apr 1, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Author

@frankyn, kokoro failed in TestStorageCompose.test_compose_create_new_blob_wo_content_type. Not related I assume

_______ TestStorageCompose.test_compose_create_new_blob_wo_content_type ________

self = <test_system.TestStorageCompose testMethod=test_compose_create_new_blob_wo_content_type>

    def test_compose_create_new_blob_wo_content_type(self):
        SOURCE_1 = b"AAA\n"
        source_1 = self.bucket.blob("source-1")
>       source_1.upload_from_string(SOURCE_1)

tests/system/test_system.py:1176:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
google/cloud/storage/blob.py:1435: in upload_from_string
    self.upload_from_file(
google/cloud/storage/blob.py:1344: in upload_from_file
    _raise_from_invalid_response(exc)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

error = InvalidResponse('Request failed with status code', 403, 'Expected one of', <HTTPStatus.OK: 200>)

    def _raise_from_invalid_response(error):
        """Re-wrap and raise an ``InvalidResponse`` exception.

        :type error: :exc:`google.resumable_media.InvalidResponse`
        :param error: A caught exception from the ``google-resumable-media``
                      library.

        :raises: :class:`~google.cloud.exceptions.GoogleCloudError` corresponding
                 to the failed status code
        """
        response = error.response
        error_message = str(error)

        message = u"{method} {url}: {error}".format(
            method=response.request.method, url=response.request.url, error=error_message
        )

>       raise exceptions.from_http_status(response.status_code, message, response=response)
E       google.api_core.exceptions.Forbidden: 403 POST https://storage.googleapis.com/upload/storage/v1/b/new_1585772487875/o?uploadType=multipart: ('Request failed with status code', 403, 'Expected one of', <HTTPStatus.OK: 200>)
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@IlyaFaer IlyaFaer changed the title fix(storage): use OrderedDict() while encoding POST policy fix(storage): use OrderedDict while encoding POST policy Apr 1, 2020
IlyaFaer added 2 commits April 1, 2020 23:39
IlyaFaer
fix(storage): use OrderedDict() while encoding POST policy
73aca83
IlyaFaer
Merge branch 'post_policies_flaky_fix' of https://github.com/q-logic/…
dfb2d5b
…python-storage into post_policies_flaky_fix
@frankyn frankyn added kokoro:force-run Add this label to force Kokoro to re-run the tests. and removed kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Apr 1, 2020
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Apr 1, 2020
frankyn
frankyn approved these changes Apr 1, 2020
View reviewed changes

@frankyn frankyn left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving, one side note. Thanks @IlyaFaer

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread google/cloud/storage/client.py
"expiration": policy_expires.isoformat() + "Z",
}.items()
)
),

@frankyn frankyn Apr 1, 2020

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little concerned about imposing order in signing code given it's only used for conformance tests.

However, it doesn't change the outcome of expectation and will work as expected as a user.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@frankyn
frankyn merged commit df560e1 into googleapis:master Apr 1, 2020
@IlyaFaer
IlyaFaer deleted the post_policies_flaky_fix branch April 1, 2020 21:40
cojenco pushed a commit to cojenco/python-storage that referenced this pull request Oct 13, 2021
Gurov Ilya @cojenco
fix(storage): use OrderedDict while encoding POST policy (googleapis#95)
f5f862b
* use OrderedDict() while encoding POST policy

* fix(storage): use OrderedDict() while encoding POST policy
cojenco pushed a commit to cojenco/python-storage that referenced this pull request Oct 13, 2021
Gurov Ilya @cojenco
fix(storage): use OrderedDict while encoding POST policy (googleapis#95)
112bcb8
* use OrderedDict() while encoding POST policy

* fix(storage): use OrderedDict() while encoding POST policy
@release-please release-please Bot mentioned this pull request Jan 12, 2022
chore(main): release 3.0.0 #688
Closed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

1 more reviewer
@frankyn frankyn frankyn approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

api: storage Issues related to the googleapis/python-storage API. cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@IlyaFaer @frankyn @googlebot @yoshi-kokoro
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.