MunifTanjim / node-bitbucket

Bitbucket API client for Browser and Node.js
https://bitbucketjs.netlify.app
MIT License
106 stars 28 forks source link

Fetching files with `source.read` fails to fetch nested files #58

Closed mdlavin closed 4 years ago

mdlavin commented 4 years ago

When fetching files nested in subdirectories, it looks like the source.read API might be URL escaping the paths separators in the path argument. Pre-v2 I had code that was fetching nested files, but now it fails with errors like this:

 error: {
    type: 'error',
    error: { message: 'No such file or directory: deploy/dependencies.yaml' }
  },
  request: {
    method: 'GET',
    url: 'https://api.bitbucket.org/2.0/repositories/<workspace>/<repo>/src/master/deploy%2Fdependencies.yaml',
  },
  status: 404
MunifTanjim commented 4 years ago

Are you sure that file exists?

Cause, I just did this and it worked perfectly:

bb.source
  .read({
    node: 'master',
    path: '.modules/init.sh',
    repo_slug: '.dotfiles',
    workspace: 'MunifTanjim'
  })
mdlavin commented 4 years ago

Well that's embarrassing 🤦 . It looks like shape of errors changed from v1 to v2 and my old method of detecting a missing file was not triggered. Sorry about the confusion; Completely my fault.

MunifTanjim commented 4 years ago

😅 no worries.