decolua/9router · error · Error

Invalid host:port:user:pass format

Error message

Invalid host:port:user:pass format

What it means

ProxyPoolsPage's batch-import parser throws this when a line splits into exactly 4 colon-separated parts but any of host, port, username, or password is empty. It is a per-line validation guard converting `host:port:user:pass` into an authenticated proxy URL.

Source

Thrown at src/app/(dashboard)/dashboard/proxy-pools/page.js:467

  const parseProxyLine = (line) => {
    const trimmed = line.trim();
    if (!trimmed) return null;

    if (trimmed.includes("://")) {
      const parsed = new URL(trimmed);
      const hostLabel = parsed.port ? `${parsed.hostname}:${parsed.port}` : parsed.hostname;
      return {
        proxyUrl: parsed.toString(),
        name: `Imported ${hostLabel}`,
      };
    }

    const parts = trimmed.split(":");
    if (parts.length === 4) {
      const [host, port, username, password] = parts;
      if (!host || !port || !username || !password) {
        throw new Error("Invalid host:port:user:pass format");
      }

      const proxyUrl = `http://${encodeURIComponent(username)}:${encodeURIComponent(password)}@${host}:${port}`;
      const parsed = new URL(proxyUrl);
      return {
        proxyUrl: parsed.toString(),
        name: `Imported ${host}:${port}`,
      };
    }

    throw new Error("Unsupported format");
  };

  const handleBatchImport = async () => {
    const lines = batchImportText
      .split(/\r?\n/)
      .map((line) => line.trim())
      .filter(Boolean);

View on GitHub (pinned to 90b52e06ff)

Solutions

  1. Supply all four fields host:port:user:pass with no empty segment
  2. Remove trailing/leading colons from the line
  3. Validate each line before submitting (regex like /^[^:\s]+:\d+:[^:]*:[^:]*$/ with non-empty groups)
  4. Check the source list for rows where credentials were redacted or lost

Example fix

// before
const [host, port, username, password] = parts;
if (!host || !port || !username || !password) {
  throw new Error("Invalid host:port:user:pass format");
}
// after — skip/collect bad lines instead of aborting the whole batch
if (!host || !port || !username || !password) {
  errors.push(`line ${i + 1}: invalid host:port:user:pass`);
  continue;
}
Defensive patterns

Strategy: validation

Validate before calling

// validate one line before import
const re = /^[^:\s]+:\d+:[^:]+:[^:]+$/;
if (!re.test(line.trim())) throw new Error("Invalid host:port:user:pass format");

Try / catch

try {
  const proxy = parseProxyLine(line);
  results.push(proxy);
} catch (err) {
  lineErrors.push(`Line ${i + 1}: ${err.message}`);
}

Prevention

When it happens

Trigger: Batch import line like `:8080:user:pass`, `host::user:pass`, `host:port::pass`, or `host:port:user:` — four segments present but at least one empty after trimming.

Common situations: Copy-pasting proxy lists with missing fields; trailing colons from truncated rows; spreadsheet exports that leave blank cells; whitespace-only segments after manual editing.

Related errors


AI-assisted analysis of decolua/9router@90b52e06ff (2026-08-30). Data as JSON: /api/errors/d2759d30a2ac40d4. Report an issue: GitHub.