Skip to content

Conversation

@VaibhavAcharya
Copy link
Contributor

@VaibhavAcharya VaibhavAcharya commented Sep 23, 2025

Summary

Fixes #EX-835

Problem Description

The zip deploy flow was failing for projects without git repositories when using the --upload-source-zip flag. The failure occurred during zip file creation with the error:

Error: Command failed: zip -r /tmp/.../workspace-snapshots/source-xxx.zip . -x node_modules/* ...
zip I/O error: No such file or directory
zip error: Could not create output file

Root Cause

The issue was that the zip command was trying to create a file at a path like /tmp/abc123/workspace-snapshots/source-xxx.zip, but the workspace-snapshots/ subdirectory didn't exist within the temporary directory.

The Netlify API provides filenames that include subdirectory paths, but the CLI wasn't creating the necessary directory structure before attempting to write the zip file.

Reproduction Steps

To reproduce this issue:

  1. Create a test directory with some files (no git repo)
  2. Run: netlify deploy --upload-source-zip --json --draft --dir . --no-build
  3. Observe the zip command failure

Example reproduction:

mkdir test-deploy && cd test-deploy
echo "<h1>Test</h1>" > index.html
netlify deploy --upload-source-zip --json --draft --dir . --no-build

Solution

  1. Added directory creation before zip file creation in src/utils/deploy/upload-source-zip.ts:

    // Ensure the directory for the zip file exists
    // The filename from the API includes a subdirectory path (e.g., 'workspace-snapshots/source-xxx.zip')
    // While temporaryDirectory() creates a new empty directory, the subdirectory within it doesn't exist
    // so we need to create it before the zip command can write the file
    await mkdir(dirname(zipPath), { recursive: true });
  2. Also improved exclusion patterns from node_modules to node_modules* for more complete directory exclusion.


For us to review and ship your PR efficiently, please perform the following steps:

  • Open a bug/issue before writing your code 🧑‍💻. This ensures we can discuss the changes and get feedback from everyone that should be involved. If you`re fixing a typo or something that`s on fire 🔥 (e.g. incident related), you can skip this step.
  • Read the contribution guidelines 📖. This ensures your code follows our style guide and
    passes our tests.
  • Update or add tests (if any source code was changed or added) 🧪
  • Update or add documentation (if features were changed or added) 📝
  • Make sure the status checks below are successful ✅

A picture of a cute animal (not mandatory, but encouraged)

@VaibhavAcharya VaibhavAcharya requested a review from a team as a code owner September 23, 2025 16:38
@github-actions
Copy link

github-actions bot commented Sep 23, 2025

📊 Benchmark results

Comparing with 28de6c7

  • Dependency count: 1,079 (no change)
  • Package size: 298 MB ⬆️ 0.01% increase vs. 28de6c7
  • Number of ts-expect-error directives: 381 (no change)

@VaibhavAcharya
Copy link
Contributor Author

VaibhavAcharya commented Sep 23, 2025

Ignore the failing tests, they are not failing. They work after a retry. 😭

Some tests in this repo are indeterministic or the setup isn't right.
Debugging for some other time.

@VitaliyR
Copy link
Contributor

@VaibhavAcharya please use expect(mockFs.mkdir).toHaveBeenCalledWith(path.join(...)) to fix tests

@VaibhavAcharya VaibhavAcharya added the automerge Add to Kodiak auto merge queue label Sep 24, 2025
@kodiakhq kodiakhq bot merged commit d547ef8 into main Sep 24, 2025
47 checks passed
@kodiakhq kodiakhq bot deleted the fix--zip-based-deploys-ignore-pattern-and-subdir-case branch September 24, 2025 06:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automerge Add to Kodiak auto merge queue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants