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

File.from picks up incorrect bucket name from passed URL #2448

Closed
IchordeDionysos opened this issue Apr 26, 2024 · 3 comments · Fixed by #2449
Closed

File.from picks up incorrect bucket name from passed URL #2448

IchordeDionysos opened this issue Apr 26, 2024 · 3 comments · Fixed by #2449
Assignees
Labels
api: storage Issues related to the googleapis/nodejs-storage API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@IchordeDionysos
Copy link

I'm going crazy here, as I'm exactly replicating the test case: https://github.com/googleapis/nodejs-storage/pull/2432/files#diff-84c67ae7b647502a4aa36d73e488640768b074793ad0b8c940a22af156e96f0b
And there it worked.

The test also did run: https://github.com/googleapis/nodejs-storage/actions/runs/8440365167/job/23117068589?pr=2432#step:8:689
image

Though for me the bucket name is always gs ...

When running the regex in the browser it is clear why the issue exists:
image
The bucket name is at index [0][2] but here it's accessed by index [0][1]

(though I don't understand why the test wouldn't have caught it)

Environment details

  • OS: macOS
  • Node.js version: v20.11.0
  • npm version: 10.2.4
  • @google-cloud/storage version: 7.10.1

Steps to reproduce

  1. Run npx gts init (use defaults)
  2. Run npm i @google-cloud/storage
  3. Run npm i ts-node
  4. Add the following script: "start": "ts-node ./src/index.ts",
  5. Change the src/index.ts to:
import {Storage, File} from '@google-cloud/storage';

const file = File.from(
  'gs://mybucket/myfile',
  new Storage({
    projectId: 'simpleclub',
  })
);
console.log(file.bucket.name); // 'gs'
  1. Run using npm run start

Making sure to follow these steps will guarantee the quickest resolution possible.

Thanks!

@IchordeDionysos IchordeDionysos added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Apr 26, 2024
@product-auto-label product-auto-label bot added the api: storage Issues related to the googleapis/nodejs-storage API. label Apr 26, 2024
@IchordeDionysos
Copy link
Author

/cc @ddelgrosso1 maybe you have some idea why this is happening for me 🤔

@ddelgrosso1 ddelgrosso1 self-assigned this Apr 26, 2024
@ddelgrosso1
Copy link
Contributor

Hi @IchordeDionysos I just want to confirm something, are you running this from a browser based application or from a node environment (you mentioned Node 20.11.0)?

@ddelgrosso1
Copy link
Contributor

I see the problem. I will get a fix in ASAP.

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. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants