Project Page Shows "Forbidden" Due to Name Lookup Failure
TOC
Problem DescriptionRoot CauseTroubleshootingStep 1: Check Harbor Core LogsStep 2: Verify in DatabaseSolutionREINDEX Risk NotesProblem Description
Some Harbor projects display forbidden error on the web UI when accessing repositories or other project details. The API returns 403:
Other projects work normally. The issue may appear after Harbor upgrade.
Root Cause
The project name stored in the database project table has been corrupted (e.g. invisible characters or encoding issues). When Harbor queries the project by name via ORM:
The equality check fails and returns no rows, even though the row exists and can be found by project_id. Since the project lookup fails, the permission check returns false, and the API responds with 403 Forbidden instead of the actual data.
Related upstream issue: https://github.com/goharbor/harbor/issues/15620
Troubleshooting
Step 1: Check Harbor Core Logs
Look for the following error pattern in harbor-core logs:
The full log chain typically looks like:
Step 2: Verify in Database
Connect to the Harbor database (registry):
Run the following queries:
If the first query returns the project but the second returns 0 rows, the issue is confirmed.
Solution
In the Harbor database (registry), rewrite the name field using project_id:
Verify the fix:
Refresh the Harbor web UI to confirm the 403 error is resolved.
REINDEX Risk Notes
REINDEX TABLE project rebuilds all indexes on the project table. It is a non-destructive operation (does not modify any data rows), but there are some risks to be aware of:
Recommendations:
- For production environments, execute during a low-traffic maintenance window to minimize the impact of the write lock.
- For the
projecttable specifically, the data volume is typically very small (tens to hundreds of rows), so the lock duration is negligible. - If zero-downtime is required, PostgreSQL 12+ supports
REINDEX TABLE CONCURRENTLY project, which builds the new index without holding an exclusive lock. However, this takes longer and requires more disk space.