felangel / mason

Tools which allow developers to create and consume reusable templates called bricks.
https://docs.brickhub.dev
932 stars 93 forks source link

FileSystemException: Creation failed. (OS Error: File name too long, errno = 63) #1344

Open jtmuller5 opened 3 weeks ago

jtmuller5 commented 3 weeks ago

Description

I am attempting to share a private brick with another developer by including a GitHub personal access token in the git url:

bricks:
  fast_app:
    git:
      url: https://CodeOTR:github_pat_11ALOGDJY0vn1GnxTviLBe_nBcG9xOV2eUBIuPNORN........@github.com/CodeOTR/flutterfaster_bricks
      path: bricks/fast_app

Because the URL is so long, however, mason get throws an error:

FileSystemException: Creation failed, path = '/Users/josephmuller/.mason-cache/git/flutterfaster_bricks_aHR0cHM6Ly9Db2RlT1RSOmdpdGh1Yl9wYXRfMTFBTE9HREpZMHZuMUdueFR2aUxCZV9uQmNHOXhPVjJlVUJJdVBOT1JOUzNtT3dQZVVWbTBWM2k5bEdNSVVqTWhRQ1UzVVc1VjJMVnRqV1VVQUBnaXRodWIuY29tL0NvZGVPVFIvZmx1dHRlcmZhc3Rlcl9icmlja3M=_4a84d0db6d0372fd9b1c2062d43505cd35a8cdd2' (OS Error: File name too long, errno = 63)

Steps To Reproduce

  1. Create a new GitHub repo
  2. Create a PAT with the "content" permission
  3. Add a brick to the new repo
  4. In a Flutter/dart project, create a mason.yaml file and add the brick you just created by adding your username and PAT to the git url

Ex.

ricks:
  fast_app:
    git:
      url: https://<USER NAME>:<PAT>@github.com/CodeOTR/flutterfaster_bricks
      path: bricks/fast_app

Expected Behavior

This should not break. I would expect the file name to be shortened to a reasonable length. Currently it seems like a hash of the git URL.

jtmuller5 commented 3 weeks ago

The issue is in this function:

String _encodedGitDir(GitPath git, String commitHash) {
  final name = p.basenameWithoutExtension(git.url);
  final path = git.url.replaceAll(r'\', '/');
  final url = base64.encode(utf8.encode(path));
  return '${name}_${url}_$commitHash';
}
felangel commented 3 weeks ago

This looks like a duplicate of #496