Skip to content

[SDK Validation]: handle rename scenario gracefully in findAllParentsWithFile to prevent crash#40918

Merged
raych1 merged 1 commit intomainfrom
fix/findAllParentsWithFile-enoent-crash
Mar 2, 2026
Merged

[SDK Validation]: handle rename scenario gracefully in findAllParentsWithFile to prevent crash#40918
raych1 merged 1 commit intomainfrom
fix/findAllParentsWithFile-enoent-crash

Conversation

@raych1
Copy link
Member

@raych1 raych1 commented Mar 2, 2026

Problem

FindAllParentsWithFile in \eng/tools/spec-gen-sdk-runner/src/utils.ts re-throws ENOENT errors when scanning directories that no longer exist on disk. When a PR renames/restructures folder paths (e.g. keyvault folder migration PR #38668), \git diff\ reports both old and new paths. The old paths don't exist after checkout, and for paths containing data-plane or resource-manager, the code crashes the entire Node.js process with an uncaught exception — preventing any SDK generation from running.

Fix

  1. FindAllParentsWithFile: Changed to match F indParentWithFile behavior — catch errors, log a warning, and return early instead of re-throwing.
  2. main() in index.ts: Added top-level try-catch so unexpected exceptions properly set the pipeline step result to Failed.

…ash on renamed paths

findAllParentsWithFile was re-throwing ENOENT errors when scanning directories
that no longer exist (e.g. after a folder restructure PR renames/deletes paths).
Since git diff reports both old and new paths, deleted directories caused an
uncaught exception that crashed the entire SDK generation process.

Changed findAllParentsWithFile to match findParentWithFile behavior: log a
warning and return early instead of throwing.

Also added a top-level try-catch in index.ts main() so unexpected exceptions
properly set the pipeline step result to Failed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link

github-actions bot commented Mar 2, 2026

Next Steps to Merge

Next steps that must be taken to merge this PR:
  • ❌ The required check named Protected Files has failed. Refer to the check in the PR's 'Checks' tab for details on how to fix it and consult the aka.ms/ci-fix guide


Comment generated by summarize-checks workflow run.

@raych1 raych1 marked this pull request as ready for review March 2, 2026 19:22
@raych1 raych1 self-assigned this Mar 2, 2026
@raych1 raych1 moved this to 🔬 Dev in PR in Azure SDK EngSys 📆🎇 Mar 2, 2026
@raych1 raych1 changed the title fix: handle ENOENT gracefully in findAllParentsWithFile to prevent crash on renamed paths [SDK Validation]: handle rename scenario gracefully in findAllParentsWithFile to prevent crash Mar 2, 2026
Copy link
Member

@mikeharder mikeharder left a comment

Choose a reason for hiding this comment

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

I think we can handle this a bit more gracefully when we create the shared helper, but this is fine for now.

@raych1 raych1 merged commit d761bda into main Mar 2, 2026
75 of 79 checks passed
@raych1 raych1 deleted the fix/findAllParentsWithFile-enoent-crash branch March 2, 2026 21:12
@kurtzeborn kurtzeborn moved this from 🔬 Dev in PR to 🎊 Closed in Azure SDK EngSys 📆🎇 Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants