Environment
- Open WebUI 0.11.1
- OIKB 0.4.0
- Docker deployment
Problem
The Knowledge Base contains files and Open WebUI returns them correctly via:
GET /api/v1/knowledge/{kb_id}/files
However:
oikb ls
oikb status --kb-id
either return 0 files or fail with:
TypeError: object of type 'NoneType' has no len()
Traceback
File "/usr/local/lib/python3.11/site-packages/oikb/cli.py", line 770, in status
file_count = len(files)
TypeError: object of type 'NoneType' has no len()
Observed API responses
GET /api/v1/knowledge/
returns:
{
"items": [...],
"total": 1
}
GET /api/v1/knowledge//files
returns:
{
"items": [...],
"total": 2
}
Root cause
In oikb/client.py:
def list_kb_files(self, kb_id):
resp = self._http.get(f"/knowledge/{kb_id}")
data = resp.json()
return data.get("files", [])
The endpoint should instead be:
GET /knowledge/{kb_id}/files
and Open WebUI 0.11.1 returns file entries in:
data["items"]
rather than:
data["files"]
Proposed fix
client.py
def list_kb_files(self, kb_id):
resp = self._http.get(f"/knowledge/{kb_id}/files")
resp.raise_for_status()
data = resp.json()
return data.get("items") or data.get("files") or []
cli.py
Replace:
files = info.get("files", [])
with:
files = client.list_kb_files(kb)
This resolves both:
Environment
Problem
The Knowledge Base contains files and Open WebUI returns them correctly via:
GET /api/v1/knowledge/{kb_id}/files
However:
oikb ls
oikb status --kb-id
either return 0 files or fail with:
TypeError: object of type 'NoneType' has no len()
Traceback
File "/usr/local/lib/python3.11/site-packages/oikb/cli.py", line 770, in status
file_count = len(files)
TypeError: object of type 'NoneType' has no len()
Observed API responses
GET /api/v1/knowledge/
returns:
{
"items": [...],
"total": 1
}
GET /api/v1/knowledge//files
returns:
{
"items": [...],
"total": 2
}
Root cause
In oikb/client.py:
def list_kb_files(self, kb_id):
resp = self._http.get(f"/knowledge/{kb_id}")
data = resp.json()
return data.get("files", [])
The endpoint should instead be:
GET /knowledge/{kb_id}/files
and Open WebUI 0.11.1 returns file entries in:
data["items"]
rather than:
data["files"]
Proposed fix
client.py
def list_kb_files(self, kb_id):
resp = self._http.get(f"/knowledge/{kb_id}/files")
resp.raise_for_status()
data = resp.json()
return data.get("items") or data.get("files") or []
cli.py
Replace:
files = info.get("files", [])
with:
files = client.list_kb_files(kb)
This resolves both: