OpenViking icon indicating copy to clipboard operation
OpenViking copied to clipboard

ov add-resource fails to index GitLab repository with OAuth2 token in URL

Open walnut-tom opened this issue 7 months ago • 3 comments

Description

When adding a GitLab repository using ov add-resource with OAuth2 token embedded in the HTTPS URL, the indexing process appears to complete but does not properly index the repository content.

Steps to Reproduce

  1. Run ov add-resource https://oauth2:<token>@gitlab.example.com/group/repo.git --to viking://resources/repo --timeout 300
  2. Wait for indexing to complete (queue shows all tasks processed)
  3. Run ov tree viking://resources/repo -L 2 to inspect the indexed content

Expected Behavior

The repository should be properly indexed with all files and directories accessible via ov ls or ov tree commands.

Actual Behavior

  • Indexing process reports success with all queue tasks completed
  • ov tree only shows a single .md file or incorrect content (e.g., .html file in temp path)
  • The actual repository content is not indexed

Workaround

Cloning the repository locally first, then adding the local path works:

git clone https://oauth2:<token>@gitlab.example.com/group/repo.git /tmp/repo
ov add-resource /tmp/repo --to viking://resources/repo --timeout 600

Environment

  • OpenViking version: (please fill)
  • OS: macOS/Linux
  • GitLab version: (if known)

Additional Context

The issue may be related to how OpenViking handles authentication in URLs or processes the initial repository fetch when using embedded credentials.

walnut-tom avatar Apr 27 '26 04:04 walnut-tom

💬 我也在做记忆系统相关的工作:CausaMem,可以来看看,说不定有能借鉴的地方 🙂

MaiHHConnect avatar Apr 27 '26 07:04 MaiHHConnect

I've been looking into this — I want to follow the GitLab resource parsing path and pin down where OAuth-style URLs get rejected during indexing. Happy to send a fix.

onthebed avatar Apr 27 '26 22:04 onthebed

I re-checked this report against current main (d14c0673) and the earlier implementation PR #1838 before choosing a disposition.

I do not think #1838 should be cherry-picked as-is:

  • it bundled two unrelated fixes;
  • its repository change applied a two-path-component trimming heuristic to every HTTP(S) repository URL;
  • the automated review correctly identified that as a regression risk for forges with valid deeper paths.

Current main solves the URL-classification part differently:

  • host matching uses urlparse(...).hostname, so oauth2:<redacted>@host userinfo does not corrupt the GitLab hostname check;
  • configured self-hosted GitLab domains participate in repository detection;
  • the normalized clone URL keeps the OAuth2 userinfo and .git path intact.

I verified this locally with a credential-free placeholder URL:

https://oauth2:[email protected]/group/repo.git

With gitlab.example.com configured in code.gitlab_domains, current main reports it as a GitLab repository, resolves group/repo, and preserves the clone URL. The focused URL-helper suite also passes: 49 tests.

Could you retry on current main (or a release containing the current code-hosting URL helpers) and confirm that the self-hosted hostname is present in code.gitlab_domains? Please do not post a real token. If indexing still produces a temporary HTML/Markdown file, the most useful sanitized evidence would be:

  1. whether the failure happens during GitLab ZIP download or the fallback git clone;
  2. the first public-safe error line around that transition;
  3. the resulting ov tree shape with credentials removed.

I am keeping the issue open pending that end-to-end validation rather than proposing another speculative normalization patch.

huangruiteng avatar Jul 14 '26 13:07 huangruiteng