Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix!: allow leading slashes in file name #820

Merged
merged 10 commits into from Oct 16, 2019

Conversation

brianzinn
Copy link
Contributor

I am integrating with Google storage and the files already have a leading /. It is not possible with this package to load them. I am doing something like this now to be able to load files:

const storagePath: string = '/file.png';
const file = await storage
      .bucket(bucketName)
      .file(storagePath);

// here file.name === 'file.png', but it needs to be '/file.png' to load an existing file.

 // https://github.com/googleapis/google-cloud-node/pull/2269
 file.name = storagePath;
 file.id = encodeURIComponent(storagePath);

I went this way to make it backwards compatible, but otherwise I can update the regex to take just one /, although that may be a breaking change for some clients.

Fixes #<issue_number_goes_here> (it's a good idea to open an issue first for discussion)

  • Tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added the cla: no This human has *not* signed the Contributor License Agreement. label Aug 21, 2019
@brianzinn
Copy link
Contributor Author

@googlebot I signed it!

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added cla: yes This human has signed the Contributor License Agreement. and removed cla: no This human has *not* signed the Contributor License Agreement. labels Aug 21, 2019
@brianzinn brianzinn force-pushed the master branch 2 times, most recently from e8eba5e to b9ef7c1 Compare August 21, 2019 05:05
allow interop with other languages and current storage files with leading slash
@brianzinn
Copy link
Contributor Author

header-check is failing with this:

src/file.ts is missing a valid copyright line.
test/file.ts is missing a valid copyright line.

Both of those files have existing and unchanged copyrights...

@jkwlui jkwlui added kokoro: run kokoro:force-run Add this label to force Kokoro to re-run the tests. and removed kokoro: run labels Aug 22, 2019
@kokoro-team kokoro-team removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Aug 22, 2019
@jkwlui jkwlui changed the title Allow leading slashes in fileName to interop with other languages and existing storage feat: allow leading slashes in fileName to interop with other languages and existing storage Aug 22, 2019
@jkwlui jkwlui added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Aug 22, 2019
@kokoro-team kokoro-team removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Aug 22, 2019
@stephenplusplus
Copy link
Contributor

Thank you for digging into this and offering a fix! Having another chance to look at this after a couple of years (googleapis/google-cloud-node#2269), I think we might have taken the wrong approach earlier. Since /blah.jpg is a valid file name, as much as //blah.jpg, I think we should remove our slash-stripping behavior completely. The input should not be touched, and we should keep the original file name. What do you think?

@brianzinn
Copy link
Contributor Author

@stephenplusplus I can easily update the PR. I was mainly concerned with backwards compatibility. Some people upgrading versions may be unable to retrieve previous storage without changing code (or end up with storage in both forms). Note that rolling back will also fix getFiles(). Shall I remove the slash stripping completely?

@stephenplusplus
Copy link
Contributor

I think we should remove it, yeah. Without worrying about backward compatibility (we can bump the major), would that be the most expected behavior from our library?

@brianzinn
Copy link
Contributor Author

I'll fix PR today. Good idea to bump version.

… without options. This is a breaking change.
@codecov
Copy link

codecov bot commented Aug 23, 2019

Codecov Report

Merging #820 into master will decrease coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #820      +/-   ##
==========================================
- Coverage   95.36%   95.36%   -0.01%     
==========================================
  Files          11       11              
  Lines        1231     1230       -1     
  Branches      307      307              
==========================================
- Hits         1174     1173       -1     
  Misses         29       29              
  Partials       28       28
Impacted Files Coverage Δ
src/file.ts 98.2% <ø> (-0.01%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 96a7fc2...b258e05. Read the comment docs.

@brianzinn
Copy link
Contributor Author

For me the latest PR matches the expected behavior from your library. Let me know if I can make any additional changes or help out. Good idea to bump major version due to the nature of the change. Cheers.

@AVaksman AVaksman added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Aug 23, 2019
@kokoro-team kokoro-team removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Aug 23, 2019
@bcoe bcoe added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Aug 26, 2019
@kokoro-team kokoro-team removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Sep 18, 2019
@stephenplusplus stephenplusplus added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 14, 2019
@kokoro-team kokoro-team removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 14, 2019
@stephenplusplus stephenplusplus added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 14, 2019
@kokoro-team kokoro-team removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 14, 2019
@stephenplusplus
Copy link
Contributor

@bcoe @jkwlui is this a good time to merge this, with the breaking change?

@jkwlui jkwlui added the kokoro:run Add this label to force Kokoro to re-run the tests. label Oct 15, 2019
@kokoro-team kokoro-team removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Oct 15, 2019
@stephenplusplus stephenplusplus added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 16, 2019
@kokoro-team kokoro-team removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 16, 2019
@stephenplusplus stephenplusplus changed the title feat!: allow leading slashes in fileName to interop with other languages and existing storage fix!: allow leading slashes in fileName to interop with other languages and existing storage Oct 16, 2019
@stephenplusplus stephenplusplus changed the title fix!: allow leading slashes in fileName to interop with other languages and existing storage fix!: allow leading slashes in file name Oct 16, 2019
@stephenplusplus stephenplusplus merged commit 92e115d into googleapis:master Oct 16, 2019
@release-please release-please bot mentioned this pull request Oct 17, 2019
BYK added a commit to getsentry/sentry-javascript that referenced this pull request Jan 4, 2021
This is to upgrade the vulnerable `date-and-time` dependency. The latest version has the following breaking changes which are all okay:

- automatically detect contentType if not provided (googleapis/nodejs-storage#1190)
- drop keepAcl parameter in file copy (googleapis/nodejs-storage#1166)
- drop support for node.js 8.x
- allow leading slashes in file name (googleapis/nodejs-storage#820)
- upgrade engines field to >=8.10.0 (googleapis/nodejs-storage#688)
BYK added a commit to getsentry/craft that referenced this pull request Jan 5, 2021
This is to upgrade the vulnerable `axios` dependency. The latest version has the following breaking changes which are all okay:

- automatically detect contentType if not provided (googleapis/nodejs-storage#1190)
- drop keepAcl parameter in file copy (googleapis/nodejs-storage#1166)
- drop support for node.js 8.x
- allow leading slashes in file name (googleapis/nodejs-storage#820)
- upgrade engines field to >=8.10.0 (googleapis/nodejs-storage#688)
BYK added a commit to getsentry/craft that referenced this pull request Jan 5, 2021
This is to upgrade the vulnerable `axios` dependency. The latest version has the following breaking changes which are all okay:

- automatically detect contentType if not provided (googleapis/nodejs-storage#1190)
- drop keepAcl parameter in file copy (googleapis/nodejs-storage#1166)
- drop support for node.js 8.x
- allow leading slashes in file name (googleapis/nodejs-storage#820)
- upgrade engines field to >=8.10.0 (googleapis/nodejs-storage#688)
BYK added a commit to getsentry/sentry-javascript that referenced this pull request Jan 11, 2021
This is to upgrade the vulnerable `date-and-time` dependency. The latest version has the following breaking changes which are all okay:

- automatically detect contentType if not provided (googleapis/nodejs-storage#1190)
- drop keepAcl parameter in file copy (googleapis/nodejs-storage#1166)
- drop support for node.js 8.x
- allow leading slashes in file name (googleapis/nodejs-storage#820)
- upgrade engines field to >=8.10.0 (googleapis/nodejs-storage#688)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Breaking Change cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants