GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Handle invalid submodule names during recursive updates by Byron · Pull Request #2205 · gitpython-developers/GitPython

Conversation

@Byron

@Byron Byron commented Aug 4, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

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

P2 Badge 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_going updates 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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

chatgpt-codex-connector[bot] reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Byron and others added 2 commits August 4, 2026 11:07
@Byron @codex
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 <[email protected]>
@Byron @codex
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 <[email protected]>
@Byron
Byron force-pushed the fixup-2202 branch from f07ce4d to 4299c99 Compare August 4, 2026 09:17
@Byron
Byron marked this pull request as ready for review August 4, 2026 09:22
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 AI reviewed Aug 4, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

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 mrepo before the try in Submodule.update() so keep_going-handled validation failures don’t lead to UnboundLocalError during recursion.
  • Extend tests to cover direct recursive=True, keep_going=True updates 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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Byron
Byron merged commit f67029c into main Aug 4, 2026
49 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@Byron 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

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@Byron
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.