diegosouzapw/OmniRoute · error · Error

The selected file is not valid JSON.

Error message

The selected file is not valid JSON.

What it means

Import-format guard in the agent-bridge maintenance card: JSON.parse of the user-selected file's text threw, so the file is not valid JSON and cannot be an agent-bridge config export. The thrown localized message ('not valid JSON') fires purely client-side before any upload — the import is aborted and no config is touched.

Solutions

  1. Re-export the config from the source instance and retry
  2. Open the file in a JSON validator to find the syntax error
  3. Ensure the correct file was selected (not a YAML or truncated export)
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/app/(dashboard)/dashboard/tools/agent-bridge/components/AgentBridgeMaintenanceCard.tsx:171 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25). Data as JSON: /api/errors/8016f9771b00a5d8. Report an issue: GitHub.

Appendix: source

Thrown at src/app/(dashboard)/dashboard/tools/agent-bridge/components/AgentBridgeMaintenanceCard.tsx:171

    setPasswordModalError(null);
  };

  const handleExport = () =>
    run("export", async () => {
      const config = await fetchAgentBridgeConfig();
      downloadJson(config, `agent-bridge-config-${Date.now()}.json`);
    });

  const handleImportFile = async (e: React.ChangeEvent<HTMLInputElement>) => {
    const file = e.target.files?.[0];
    e.target.value = ""; // allow re-selecting the same file
    if (!file) return;
    await run("import", async () => {
      let parsed: unknown;
      try {
        parsed = JSON.parse(await file.text());
      } catch {
        throw new Error(t("importInvalidJson") || "The selected file is not valid JSON.");
      }
      const result: ImportResult = await importAgentBridgeConfig(parsed as AgentBridgeConfig);
      setNotice(
        (t("importDone") || "Imported {bypass} bypass · {hosts} hosts · {agents} agents")
          .replace("{bypass}", String(result.bypassPatterns))
          .replace("{hosts}", String(result.customHosts))
          .replace("{agents}", String(result.agents))
      );
      await onRefresh();
    });
  };

  return (
    <>
    <div className="rounded-xl border border-border/60 bg-card overflow-hidden">
      <div className="flex items-center gap-3 px-5 py-4">
        <div className="p-2 rounded-lg bg-primary/10">
          <span className="material-symbols-outlined text-[20px] text-primary">build</span>

View on GitHub (pinned to a179ffed5b)