Azure / Azure/aks-desktop

Projects not displayed after importing from existing namespace

Open
#487 1 comment 0 reactions 1 assignee Claimed by @gambtho View on GitHub
bug triage
Dominant language
TypeScript
Stars
102
Forks
25
Avg merge
1d 4h
Merged PRs (30d)
22

Description

## Problem

After successfully importing a project from an existing namespace, no projects are displayed on the Home page. The import command completes without errors, but the project list remains empty.

## Console Errors

Several issues appear in the browser console:

### 1. Missing React `key` prop in `AddCluster`
```
Warning: Each child in a list should have a unique "key" prop.
Check the render method of `AddCluster`.
```

**Location:** `headlamp/frontend/src/components/App/CreateCluster/AddCluster.tsx` — the `.map()` rendering `AddClusterProvider` components is missing a `key` prop.

### 2. "Error: Unreachable" from `useSidebarItems.tsx`
```
useSidebarItems.tsx:68 Error: Unreachable
at backendFetch (fetch.ts:61:11)
at async clusterFetch (fetch.ts:91:22)
```

This is thrown by `backendFetch()` when namespace API calls return non-2xx responses (502 Bad Gateway). The error message "Unreachable" is generic and unhelpful for debugging.

### 3. 502 Bad Gateway on namespace fetches
Multiple namespace queries fail with 502:
```
/clusters//api/v1/namespaces/ → 502
/clusters//api/v1/namespaces?labelSelector=headlamp.dev%2Fproject-id → 502
```

These are the exact queries that `useProjects()` uses to populate the project list. When they fail, no projects are shown.

## Root Cause Analysis

The project listing flow is:
1. `Home` → `ProjectList` → `useProjects()` hook
2. `useProjects()` queries namespaces with `labelSelector: headlamp.dev/project-id`
3. Results are grouped into `ProjectDefinition[]` and rendered

When the backend proxy returns 502 for these namespace queries, the project list gets no data and renders empty. The import itself succeeds (namespace is labeled correctly), but the UI never receives the namespace data to display.

Possible contributing factors:
- Stale kubeconfig after import (the code does `window.location.reload()` to work around this, but if the cluster is temporarily unreachable this doesn't help)
- Backend proxy unable to reach the K8s API server for certain clusters
- The `allowedNamespaces` in cluster settings may not be properly updated during import

## Steps to Reproduce

1. Open AKS Desktop
2. Navigate to import project from existing namespace
3. Select a cluster and namespace
4. Complete the import wizard
5. Observe: import succeeds, page reloads, but no projects appear
6. Check browser console for the errors above

## Expected Behavior

After a successful import, the project should appear in the project list on the Home page.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.