Skip to content

fix: append bucket name to V4 policy URL in emulator mode#2716

Open
7hokerz wants to merge 1 commit intogoogleapis:mainfrom
7hokerz:7hokerz/fix-v4-policy-url
Open

fix: append bucket name to V4 policy URL in emulator mode#2716
7hokerz wants to merge 1 commit intogoogleapis:mainfrom
7hokerz:7hokerz/fix-v4-policy-url

Conversation

@7hokerz
Copy link

@7hokerz 7hokerz commented Feb 4, 2026

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

Description

This PR fixes a bug where generateSignedPostPolicyV4 returns an incorrect URL (missing the bucket name) when the STORAGE_EMULATOR_HOST environment variable is set.
This change is scoped strictly to this method and does not modify the global apiEndpoint or Service configuration.

Impact

Updated generateSignedPostPolicyV4 in src/file.ts to explicitly append the bucket name to the URL if the client is running in emulator mode and the bucket path is missing.

Testing

Added a new test case in test/file.ts to verify that the bucket name is correctly appended to the URL when STORAGE_EMULATOR_HOST is active.
Ran existing tests: Verified that all existing tests pass (npm test) to ensure no regressions.
No breaking changes are introduced.

Additional Information

This PR is somewhat related https://github.com/googleapis/nodejs-storage/issues/2092.
But This PR avoids those issues by applying a localized fix solely for the V4 Post Policy generation instead of modifying the global service configuration.

Checklist

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease
  • Appropriate docs were updated
  • Appropriate comments were added, particularly in complex areas or places that require background
  • No new warnings or issues will be generated from this change

Fixes #issue_number_goes_here 🦕

issue: #2715

@7hokerz 7hokerz requested review from a team as code owners February 4, 2026 05:47
@product-auto-label product-auto-label bot added size: s Pull request size is small. api: storage Issues related to the googleapis/nodejs-storage API. labels Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: storage Issues related to the googleapis/nodejs-storage API. size: s Pull request size is small.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant