fix(cliproxyapi): address remaining Kilo review issues

- Wrap JSON.parse in try/catch in rowToConfig (upstreamProxy.ts)
- Add error logging to empty catch blocks in CliproxyapiToolCard
- Pin Docker image to v6.9.7 instead of :latest
This commit is contained in:
oyi77
2026-04-02 15:58:52 +07:00
parent adf77053c5
commit ad676af3f0
3 changed files with 18 additions and 7 deletions

View File

@@ -115,7 +115,7 @@ services:
# ── Profile: cliproxyapi (CLIProxyAPI as sidecar) ─────────────────
cliproxyapi:
container_name: cliproxyapi
image: ghcr.io/router-for-me/cliproxyapi:latest
image: ghcr.io/router-for-me/cliproxyapi:v6.9.7
restart: unless-stopped
ports:
- "${CLIPROXYAPI_PORT:-8317}:${CLIPROXYAPI_PORT:-8317}"

View File

@@ -32,19 +32,25 @@ export default function CliproxyapiToolCard({ isExpanded, onToggle }) {
const fetchStatus = useCallback(async () => {
try {
const res = await fetch("/api/version-manager/status");
if (!res.ok) return;
const data = await res.json();
const entry = Array.isArray(data)
? data.find((t: ToolState) => t.tool === "cliproxyapi")
: null;
setToolState(entry || null);
} catch {}
} catch (err) {
console.error("Failed to fetch CLIProxyAPI status:", err);
}
}, []);
const fetchUpdateInfo = useCallback(async () => {
try {
const res = await fetch("/api/version-manager/check-update?tool=cliproxyapi");
if (!res.ok) return;
setUpdateInfo(await res.json());
} catch {}
} catch (err) {
console.error("Failed to fetch CLIProxyAPI update info:", err);
}
}, []);
useEffect(() => {

View File

@@ -74,14 +74,19 @@ export function validateProxyUrl(
}
function rowToConfig(record: Record<string, unknown>): UpstreamProxyConfig {
let mapping: Record<string, unknown> | null = null;
if (record.cliproxyapi_model_mapping && typeof record.cliproxyapi_model_mapping === "string") {
try {
mapping = JSON.parse(record.cliproxyapi_model_mapping);
} catch {
mapping = null;
}
}
return {
id: record.id as number,
providerId: record.provider_id as string,
mode: record.mode as string,
cliproxyapiModelMapping:
record.cliproxyapi_model_mapping && typeof record.cliproxyapi_model_mapping === "string"
? JSON.parse(record.cliproxyapi_model_mapping)
: null,
cliproxyapiModelMapping: mapping,
nativePriority: record.native_priority as number,
cliproxyapiPriority: record.cliproxyapi_priority as number,
enabled: record.enabled === 1 || record.enabled === true,