fix(PROD-2277): models-only sync crashes in push with ENOENT on galleries folder#173
Open
5PK wants to merge 2 commits into
Open
fix(PROD-2277): models-only sync crashes in push with ENOENT on galleries folder#1735PK wants to merge 2 commits into
5PK wants to merge 2 commits into
Conversation
…nc doesn't ENOENT A models-only sync (--models / --elements="Models") skips downloading galleries (the PROD-2215 optimization), so agility-files/<guid>/galleries is never created. But the push-side loader still reads it unconditionally: guid-data-loader -> getGalleriesFromFileSystem -> fileOperations.getFolderContents -> fs.readdirSync, which threw ENOENT and aborted the whole sync. Make getFolderContents create the folder and return [] when it is absent, matching the guards already present in readJsonFilesFromFolder/listFilesInFolder. Creating the folder (not just guarding the read) also restores the instance-folder scaffolding downstream steps assume. All four callers want "list files, empty if none", so auto-create is safe. Adds a regression test. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ing folder This test previously asserted the old buggy behavior — that a missing galleries folder throws (the ENOENT that crashed a models-only sync). Update it to assert the fixed behavior: returns [], creates the folder, and does not throw. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A models-only sync —
sync --models="X"(and the same code path for--elements="Models") — crashes in the push phase on a clean machine:This is a regression from PROD-2215 (#166). That fix correctly makes a models-only scope download only model definitions (skipping assets, galleries, content) — but the push-side loader still reads the galleries folder unconditionally, and that folder is now never created.
Root cause
guid-data-loader.ts(~L85, ~L400) callsgetGalleriesFromFileSystem()unconditionally during push.get-galleries.ts→fileOperations.getFolderContents()→fs.readdirSync(folder)with no existence guard (fileOperations.ts~L273).agility-files/<guid>/galleries(even empty), soreaddirSyncreturned[]. PROD-2215 stopped creating it for models-only runs →ENOENT.Fix
getFolderContentsnow creates the folder on demand and returns[]when absent, matching the guards already inreadJsonFilesFromFolder/listFilesInFolder:Creating the folder (rather than only guarding the read) also restores the consistent instance-folder scaffolding downstream steps assume. All four callers (get-galleries, gallery-mapper, mapping-reader ×2) want "list files, empty if none", so auto-create is safe.
Testing
sync --sourceGuid=… --targetGuid=… --models="AssetTest"(no localagility-files, no workaround) →✓ Sync completed successfully; galleries/assets correctly skipped in push; folders auto-created.fileOperations.test.ts(missing folder → returns[]and folder is created).Jira: PROD-2277
🤖 Generated with Claude Code