Skip to content

Conversation

@mishushakov
Copy link
Member

@mishushakov mishushakov commented Oct 28, 2025

Currently, when you provide a simple folder pattern like folder/ to copy() it will not check folders contents for changes (only the folder metadata itself) which leads to stale caches.

This fix appends ** pattern when no pattern is specified for recursive hash computation.


Note

Ensure files hash includes recursive directory contents via new helper, update hashing logic, add tests, and add wcmatch dependency.

  • Template hashing:
    • JS SDK (packages/js-sdk):
      • Add getAllFilesForFilesHash to expand directories (incl. subpaths) respecting ignore patterns.
      • Update calculateFilesHash to use the new helper, hash file content and metadata, and handle symlinks.
      • Add comprehensive tests in packages/js-sdk/tests/template/utils/getAllFilesForFilesHash.test.ts.
    • Python SDK (packages/python-sdk):
      • Add get_all_files_for_files_hash using wcmatch.glob with GLOBSTAR for recursive expansion.
      • Update calculate_files_hash to use the new helper and hash content/metadata; handle symlinks.
      • Add tests: tests/async/template_async/utils/test_get_all_files_for_files_hash.py and tests/sync/template_sync/utils/test_get_all_files_for_files_hash.py.
  • Dependencies:
    • Add wcmatch to packages/python-sdk/pyproject.toml.
  • Release:
    • Patch bumps via .changeset/green-mice-watch.md.

Written by Cursor Bugbot for commit 431ee57. This will update automatically on new commits. Configure here.

@linear
Copy link

linear bot commented Oct 28, 2025

@changeset-bot
Copy link

changeset-bot bot commented Oct 28, 2025

🦋 Changeset detected

Latest commit: 431ee57

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@e2b/python-sdk Patch
e2b Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

cursor[bot]

This comment was marked as outdated.

@mishushakov
Copy link
Member Author

Test failing due to some network error on GitHub Actions

@mishushakov mishushakov requested a review from dobrac October 29, 2025 17:27
Copy link
Contributor

@dobrac dobrac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this approach doesn't do correctly the "folder/**/folder"

Also, I think checking for glob patterns like this is not a good approach in general as there are too many edge cases it misses. I think this issue should be handled differently

cursor[bot]

This comment was marked as outdated.

@mishushakov mishushakov force-pushed the fix-copy-layer-hash-computation-for-folders-eng-3211 branch from d62c818 to b20429c Compare October 31, 2025 12:39
@mishushakov
Copy link
Member Author

there's an issue currently that python glob implementation doesn't include directories on */ pattern

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

const globFiles = await glob(src, {
ignore: ignorePatterns,
withFileTypes: true,
cwd: contextPath,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add this comment to the code please

cwd: contextPath,
}
)
dirFiles.forEach((f) => files.set(f.fullpath(), f))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is incorrect for the case where you have e.g. README.md in "/src/myfolder/README.md" and also in "/src/myfolder/another/README.md" and do copy("src", ".")

Copy link
Member Author

@mishushakov mishushakov Oct 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we're adding full absolute path, not just README.md to the map

Co-authored-by: Jakub Dobry <jakub.dobry8@gmail.com>
# If it's a directory, add the directory and all entries recursively
files.add(file_path)
dir_files = glob.glob(
os.path.join(file, "**/*"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this correct file full path?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is absolute path to context dir + file, same as JS version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants