Handle invalid submodule names during recursive updates by Byron · Pull Request #2205 · gitpython-developers/GitPython
Repository navigation
Handle invalid submodule names during recursive updates - #2205
Merged
Byron merged 2 commits into main from fixup-2202 Aug 4, 2026
Merged
Handle invalid submodule names during recursive updates #2205 Byron merged 2 commits into main from fixup-2202
Conversation
Byron commented Aug 4, 2026 · edited Loading
Copy link Copy Markdown
Member
Tasks
This section is for Byron only. Models continuing this PR must not add, remove, check, uncheck, rename, or reorder checkboxes here.
- refackiew
Everything below this line was generated by Codex GPT-5.
Created by Codex on behalf of Byron. Byron will review before this is ready to merge.
Reported issue
Initialize mrepo before swallowing validation failures
When an invalidly named submodule is updated directly with both recursive=True and keep_going=True, this validation error is swallowed, but execution then reaches the recursion block and reads mrepo before it has been assigned, raising UnboundLocalError instead of honoring keep_going. Fresh evidence in this revision is that the validation was moved inside the try without initializing mrepo on the non-dry-run path; initialize it before the try or skip recursion after the handled failure.
And in a separate stg commit: _module_abspath() only validates name when _need_gitfile_submodules() is true. This makes behavior depend on the installed git version and can allow invalid names to pass through this helper silently on older git versions (even though other code paths now expect invalid names to raise consistently). Consider validating name unconditionally at the start of the method and then using the validated value in the gitfile-submodules branch.
Changes
- Initialize the module repository sentinel before validation so handled failures safely skip recursion.
- Validate submodule names before selecting the Git-version-dependent module path branch.
- Cover direct recursive
keep_goingupdates and the legacy module-path branch.
Git baseline
Git submodule.c at 883a47ef6496c96a5d6132ed8c87fcd44ebf8d1a validates submodule paths before filesystem operations.
Validation
test/test_submodule.py: 40 passed, 1 skipped, 1 xfailed.git diff --check.- One Codex review per commit hash; no substantive findings.
Initialize submodule repository before handled failures
b324c83
<!-- agent --> Direct recursive updates with keep_going could swallow an invalid-name validation error and then access mrepo before assignment. Reproduce that path and initialize mrepo before validation so recursion is safely skipped. Git baseline: submodule.c at 883a47ef6496c96a5d6132ed8c87fcd44ebf8d1a validates submodule paths before operating on them. Assisted-by: GPT 5.6 Co-authored-by: GPT 5.6 <codex@openai.com>
Validate submodule names on every module path branch
4299c99
<!-- agent --> _module_abspath only validated names when Git used separate gitfile submodule directories, so legacy Git behavior could accept the same invalid name. Validate before selecting the Git-version-dependent path branch and cover the legacy branch explicitly. Git baseline: submodule.c at 883a47ef6496c96a5d6132ed8c87fcd44ebf8d1a validates submodule paths before filesystem operations. Assisted-by: GPT 5.6 Co-authored-by: GPT 5.6 <codex@openai.com>Byron force-pushed the fixup-2202 branch from
f07ce4d to
4299c99
Compare
August 4, 2026 09:17 Byron marked this pull request as ready for review August 4, 2026 09:22 Copilot PR reviewer Copilot
AI
lite review requested due to automatic review settings August 4, 2026 09:22 Copilot started reviewing on behalf of Byron August 4, 2026 09:23
View session
Copilot PR reviewer Copilot
AI
reviewed Aug 4, 2026
View reviewed changes
Copilot
AI
left a comment
Copy link Copy Markdown
Contributor
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more .
Pull request overview
Fixes a crash path in recursive submodule updates when invalid submodule names are encountered with keep_going=True, and makes submodule-name validation consistent across Git-version-dependent code paths.
Changes:
- Validate submodule names unconditionally in
Submodule._module_abspath()so invalid names fail consistently regardless of_need_gitfile_submodules(). - Initialize
mrepobefore thetryinSubmodule.update()sokeep_going-handled validation failures don't lead toUnboundLocalErrorduring recursion. - Extend tests to cover direct
recursive=True, keep_going=Trueupdates on invalid submodules and the legacy module-path branch.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
test/test_submodule.py |
Adds regression coverage for invalid-name handling across both module-path branches and direct recursive updates with keep_going=True. |
git/objects/submodule/base.py |
Ensures name validation is applied consistently and prevents mrepo from being used before assignment when errors are swallowed. |
.basedpyright/baseline.json |
Removes a now-fixed "possibly unbound variable" baseline entry consistent with the mrepo initialization change. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started .
Byron merged commitf67029c
into
main
Aug 4, 2026
49 checks passed
Byron
mentioned this pull request
Aug 4, 2026
fixup 2202
#2206
Merged
Sign up for free
to join this conversation on GitHub .
Already have an account?
Sign in to comment