mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-10-25 01:45:23 +08:00
fix(install-diagnostics): Sanitize plugin installation network diagnostics (LANG-132)
This commit is contained in:
@@ -32,6 +32,24 @@ const stageKeys: Record<string, string> = {
|
||||
done: 'plugins.installProgress.completed',
|
||||
};
|
||||
|
||||
function networkDiagnosticKey(kind: string) {
|
||||
switch (kind) {
|
||||
case 'connect_timeout':
|
||||
case 'read_timeout':
|
||||
case 'write_timeout':
|
||||
case 'pool_timeout':
|
||||
return 'pipelineMigration.networkDiagnostics.timeout';
|
||||
case 'connect_error':
|
||||
return 'pipelineMigration.networkDiagnostics.connection';
|
||||
case 'incomplete_response':
|
||||
return 'pipelineMigration.networkDiagnostics.incomplete';
|
||||
case 'http_status':
|
||||
return 'pipelineMigration.networkDiagnostics.http';
|
||||
default:
|
||||
return 'pipelineMigration.networkDiagnostics.network';
|
||||
}
|
||||
}
|
||||
|
||||
function bytes(value: number) {
|
||||
return value < 1024 * 1024
|
||||
? `${(value / 1024).toFixed(1)} KB`
|
||||
@@ -163,6 +181,15 @@ export default function MigrationInstallProgress({
|
||||
</Button>
|
||||
</CollapsibleTrigger>
|
||||
<CollapsibleContent className="space-y-2 pt-1 text-xs">
|
||||
{failed && item.diagnostic && (
|
||||
<p className="text-muted-foreground">
|
||||
{t(networkDiagnosticKey(item.diagnostic.kind))}
|
||||
{Number.isInteger(item.diagnostic.http_status) &&
|
||||
item.diagnostic.http_status! >= 100 &&
|
||||
item.diagnostic.http_status! <= 599 &&
|
||||
` (HTTP ${item.diagnostic.http_status})`}
|
||||
</p>
|
||||
)}
|
||||
<p className="break-all text-muted-foreground">
|
||||
{item.author}/{item.name}
|
||||
</p>
|
||||
|
||||
@@ -66,6 +66,7 @@ export interface MigrationInstallation {
|
||||
status: 'installing' | 'completed' | 'failed';
|
||||
stage: string;
|
||||
code: string | null;
|
||||
diagnostic?: { kind: string; http_status?: number };
|
||||
progress_percent?: number;
|
||||
download_current?: number;
|
||||
download_total?: number;
|
||||
|
||||
Reference in New Issue
Block a user