seaweedfs/seaweedfs · error · Error
Failed to fetch group
Error message
Failed to fetch group
What it means
In the SeaweedFS admin UI (weed/admin/view/app/groups.templ), refreshGroupDetails fetches GET {basePath}/api/groups/{name} and throws Error('Failed to fetch group') on any non-2xx response (groups.templ:271-272). The function's catch only logs to console.error (groups.templ:332-334), so the View Group modal still opens but renders stale or empty member/policy tables.
Source
Thrown at weed/admin/view/app/groups.templ:272
const error = await response.json().catch(() => ({}));
showAlert('Failed to create group: ' + (error.error || 'Unknown error'), 'error');
}
} catch (error) {
showAlert('Failed to create group: ' + error.message, 'error');
}
}
async function viewGroup(name) {
currentGroupName = name;
document.getElementById('viewGroupTitle').textContent = 'Group: ' + name;
await refreshGroupDetails(name);
new bootstrap.Modal(document.getElementById('viewGroupModal')).show();
}
async function refreshGroupDetails(requestedName) {
try {
const response = await fetch(basePath('/api/groups/' + encodeURIComponent(requestedName)));
if (!response.ok) throw new Error('Failed to fetch group');
if (requestedName !== currentGroupName) return; // stale response
const group = await response.json();
// Render members using DOM APIs to prevent XSS
const membersList = document.getElementById('membersList');
membersList.innerHTML = '';
const membersTable = document.createElement('table');
membersTable.className = 'table table-sm';
const membersTbody = document.createElement('tbody');
if (group.members && group.members.length > 0) {
for (const member of group.members) {
const tr = membersTbody.insertRow();
const td1 = tr.insertCell();
td1.textContent = member;
const td2 = tr.insertCell();
const btn = document.createElement('button');
btn.className = 'btn btn-sm btn-outline-danger';
btn.onclick = () => removeMember(member);View on GitHub (pinned to 1c926e8fac)
Solutions
- Reload the groups page and retry — the group most likely no longer exists
- Open browser devtools Network tab and check the actual status: 401/403 → re-authenticate; 500 → inspect weed server logs; 404 → deleted group or wrong path
- Verify basePath/reverse-proxy config so the UI requests the correct /api/... URL
- Improve the handler: include response.status/response.statusText in the error and surface it in the modal instead of only console.error
Example fix
// before
if (!response.ok) throw new Error('Failed to fetch group');
// ... catch (error) { console.error('Error fetching group details:', error); }
// after
if (!response.ok) throw new Error('Failed to fetch group: ' + response.status + ' ' + response.statusText);
// ... catch (error) {
console.error('Error fetching group details:', error);
document.getElementById('membersList').innerHTML = '<div class="alert alert-danger">' + error.message + '</div>';
} Defensive patterns
Strategy: try-catch
Validate before calling
async function groupExists(name) {
const r = await fetch(basePath('/api/groups/' + encodeURIComponent(name)));
return r.ok; // 200 → safe to open the View modal
} Try / catch
try {
const response = await fetch(basePath('/api/groups/' + encodeURIComponent(name)));
if (!response.ok) throw new Error('Failed to fetch group: ' + response.status);
// render
} catch (error) {
showErrorInModal(error.message); // surface in the modal, not only console
} Prevention
- Include response.status in thrown errors so 401/500 are distinguishable from 404
- Reload the groups list when a view fetch fails — stale tables are the usual cause
- Keep admin sessions short-lived and re-fetch before mutating/detail views
When it happens
Trigger: Clicking View on a group that was deleted after the groups table was rendered (404); expired admin session (401/403); server error (500); basePath mismatch when the UI is mounted under a reverse-proxy prefix so /api/groups/... 404s.
Common situations: Two admins editing groups concurrently; leaving the admin page open past session expiry; serving the admin UI behind a proxy that strips or rewrites the /api prefix.
Related errors
- Failed to create topic
- Policy not found
- Failed to load tables
- Invalid int64 value for field
- Invalid number for field
AI-assisted analysis of seaweedfs/seaweedfs@1c926e8fac (2026-08-15).
Data as JSON: /api/errors/2afb090be8e7b35a.
Report an issue: GitHub.