Skip to content

Add Harbor fallback for catalog and search endpoints#617

Open
pguinet wants to merge 2 commits intoFinsys:mainfrom
pguinet:fix/harbor-catalog-fallback
Open

Add Harbor fallback for catalog and search endpoints#617
pguinet wants to merge 2 commits intoFinsys:mainfrom
pguinet:fix/harbor-catalog-fallback

Conversation

@pguinet
Copy link

@pguinet pguinet commented Feb 20, 2026

Summary

  • Harbor robot accounts are denied access to the V2 _catalog endpoint (scope registry:catalog:* returns an empty JWT), making catalog browsing and image search non-functional for Harbor registries
  • This PR adds automatic Harbor detection and transparently falls back to the native Harbor project API (/api/v2.0/projects/{name}/repositories) for both catalog listing and image search
  • No configuration change required — Harbor registries are detected automatically via the WWW-Authenticate header and /api/v2.0/ping, with a 5-minute cache

Changes

src/lib/server/docker.ts

  • isHarborRegistry(): detect Harbor via WWW-Authenticate + /api/v2.0/ping (result cached 5 min)
  • harborListRepositories(): list repos through Harbor project API with pagination support
  • harborSearchRepositories(): search repos using Harbor's q=name=~{term} filter
  • HarborCatalogResult type + getHarborBasicAuth() helper

src/routes/api/registry/catalog/+server.ts

  • Harbor detection before _catalog call, delegates to handleHarborCatalog()

src/routes/api/registry/search/+server.ts

  • Harbor detection in searchCatalog(), delegates to harborSearchRepositories()

Test plan

  • Tested against a real Harbor instance with a robot account
  • Catalog listing returns repositories correctly
  • Image search returns filtered results
  • Non-Harbor registries are unaffected (fallback is only triggered for Harbor)
  • Built and deployed as fnsys/dockhand:harbor-fix

Fixes #360

🤖 Generated with Claude Code

Harbor denies access to the V2 _catalog endpoint for robot accounts
(scope registry:catalog:* returns an empty JWT). This adds automatic
Harbor detection and falls back to the native Harbor project API
(/api/v2.0/projects/{name}/repositories) for both catalog listing
and image search.

- Detect Harbor via WWW-Authenticate header + /api/v2.0/ping (cached 5min)
- List repositories through Harbor project API with pagination
- Search repositories using Harbor's q=name=~ filter
- Transparent fallback: no configuration change required

Fixes Finsys#360

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@CLAassistant
Copy link

CLAassistant commented Feb 20, 2026

CLA assistant check
All committers have signed the CLA.

return { baseUrl, orgPath: parsed.path, authHeader };
}

// --- Harbor fallback pour le catalog et la recherche d'images ---
Copy link
Contributor

Choose a reason for hiding this comment

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

hi @pguinet - we need all comments to be in english.

Copy link
Author

@pguinet pguinet Feb 20, 2026

Choose a reason for hiding this comment

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

Hello @jotka - Sorry about that! I've translated all comments to English in the latest commit. Won't happen again.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

Unable to Connect to Harbor Registry

3 participants