jd-opensource/joyagent-jdgenie · error · Error
网络错误
Error message
网络错误
What it means
TableRenderer fetches fileUrl and throws Error('网络错误') ('network error') when res.ok is false, i.e. any non-2xx HTTP status, before parsing the CSV/Excel content. The table cannot render without the file data.
Solutions
- Confirm fileUrl resolves (open it in a browser) and returns 200
- Regenerate or refresh the file download URL
- Render the `error` state from useRequest with a retry action
- Check that the file type/mode matches the actual file (excel vs csv handling)
- Inspect the storage service for why the object is unavailable
Example fix
// before
const res = await fetch(fileUrl);
if (!res.ok) throw new Error('网络错误');
// after
const res = await fetch(fileUrl);
if (!res.ok) {
throw new Error(`表格加载失败 (HTTP ${res.status})`);
}
return fileType === 'excel' ? res.arrayBuffer() : res.text(); Defensive patterns
Strategy: try-catch
Validate before calling
async function assertTableAvailable(url: string): Promise<boolean> {
try {
const res = await fetch(url, { method: 'HEAD' });
return res.ok;
} catch { return false; }
} Type guard
function isOk(res: Response): res is Response & { ok: true } {
return res.ok;
} Try / catch
const { data, error, run } = useRequest(() => loadTable(fileUrl, fileType), {
refreshDeps: [fileUrl],
onError: (e) => message.error(`表格加载失败:${e.message}`),
});
if (error) return <Button onClick={run}>重新加载</Button>; Prevention
- Check res.status and include it in the thrown message for easier debugging
- Handle 401/403 by refreshing credentials before fetching
- Refresh file URLs when the file list reloads
- Distinguish excel vs csv by actual content type, not just extension
When it happens
Trigger: The spreadsheet URL returns 404 (file missing), 403 (expired link or denied access), or 5xx server error; a wrong fileUrl passed via props.
Common situations: Excel/CSV exported files deleted by cleanup jobs; presigned URL expiry; permission changes on the storage bucket; misconfigured base path in fileUrl.
Understand the failure class
Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.
Related errors
- Network response was not ok
- Network response was not ok
- 调用接口" + url + "失败:" + response.message()
- sse listener failed
- 返回结果为空!
AI-assisted analysis of jd-opensource/joyagent-jdgenie@2417e0b8b6 (2026-09-08).
Data as JSON: /api/errors/3098d8b178db93aa.
Report an issue: GitHub.
Appendix: source
Thrown at ui/src/components/ActionPanel/TableRenderer.tsx:35
/**
* 文件类型,默认为文件扩展名决定
*/
mode?: 'csv' | 'excel';
/**
* 文件名
*/
fileName?: string;
}> = (props) => {
const { fileUrl, mode, fileName } = props;
const ext = (fileName || fileUrl).split('.').pop()?.toLowerCase();
const fileType = mode || (ext === 'xlsx' || ext === 'xlsm' || ext === 'xlsb' || ext === 'xls' ? 'excel' : 'csv');
// 拉取 CSV 文本
const { data, loading, error } = useRequest(async () => {
const res = await fetch(fileUrl);
if (!res.ok) throw new Error('网络错误');
if (fileType === 'excel') {
return res.arrayBuffer();
}
return res.text();
},
{ refreshDeps: [fileUrl] }
);
// 解析 CSV
const { columns, dataSource, parseError } = useMemo(() => {
if (!data) return {
columns: [],
dataSource: [],
parseError: false
};
View on GitHub (pinned to 2417e0b8b6)