Skip to content

fix: fall back to root on an unrecognized URL path kind - #601

Open
eeshsaxena wants to merge 1 commit into
coderamp-labs:mainfrom
eeshsaxena:fix/unsupported-path-kind-fallback
Open

fix: fall back to root on an unrecognized URL path kind#601
eeshsaxena wants to merge 1 commit into
coderamp-labs:mainfrom
eeshsaxena:fix/unsupported-path-kind-fallback

Conversation

@eeshsaxena

Copy link
Copy Markdown

parse_remote_repo crashes on valid GitHub URLs whose path kind is not tree/blob/issues/pull:

from gitingest import ingest
ingest("https://github.com/user/repo/releases/tag/v1.0")
# ValueError: 'releases' is not a valid PathKind

The line kind = PathKind(path_parts.pop(0)) raises ValueError for any unrecognized segment, and ingest_async calls parse_remote_repo without catching it, so the whole ingest fails. Common URLs a user might paste hit this: /releases/..., /wiki, /actions, /commits/main, /security, etc.

It is also inconsistent: the known-but-unsupported kinds (issues, pull) already fall back to the repository root with a warning, but an unknown kind crashes instead.

This catches the ValueError and falls back to root the same way, so those URLs ingest the repository root instead of erroring. Added a regression test; the full query_parser suite passes (40 tests).

parse_remote_repo did PathKind(path_parts.pop(0)), which raises ValueError for
any path segment that is not tree/blob/issues/pull. Valid GitHub URLs such as
/releases/tag/v1.0, /wiki, /actions and /commits therefore crashed ingest()
with an uncaught ValueError, while the known-but-unsupported issues and pull
kinds already fall back to the repository root. Catch the ValueError and fall
back to root as well.
@eeshsaxena

Copy link
Copy Markdown
Author

Hi! Gentle nudge on this one whenever you have some bandwidth. It's a small, self-contained fix (fix: fall back to root on an unrecognized URL path kind), and it's currently mergeable with no conflicts. No urgency at all, and I'm happy to make any changes you'd like. Thanks for maintaining gitingest!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant