{"record":{"id":"4a257f8b73100d1c","repo":"docmirror/dev-sidecar","slug":"unknown-type-dns-server-provider-provider","errorCode":null,"errorMessage":"Unknown type DNS: ${server}, provider: ${provider}","messagePattern":"Unknown type DNS: (.+?), provider: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/mitmproxy/src/lib/dns/index.js","lineNumber":37,"sourceCode":"      let server = conf.server || conf.host\n      if (server != null) {\n        server = server.replace(/\\s+/, '')\n      }\n      if (!server) {\n        continue\n      }\n\n      // 获取DNS类型\n      let type = conf.type\n      if (type == null) {\n        if (server.startsWith('https://') || server.startsWith('http://')) {\n          type = 'https'\n        } else if (server.startsWith('tls://') || server.startsWith('dot://')) {\n          type = 'tls'\n        } else if (server.startsWith('tcp://')) {\n          type = 'tcp'\n        } else if (server.includes('://') && !server.startsWith('udp://')) {\n          throw new Error(`Unknown type DNS: ${server}, provider: ${provider}`)\n        } else {\n          type = 'udp'\n        }\n      } else {\n        type = type.replace(/\\s+/, '').toLowerCase()\n      }\n\n      // 获取DNS的Family值\n      const family = conf.family\n\n      // 创建DNS对象\n      if (type === 'https' || type === 'doh' || type === 'dns-over-https') {\n        if (!server.includes('/')) {\n          server = `https://${server}/dns-query`\n        }\n\n        // 基于 https\n        dnsMap[provider] = new DNSOverHTTPS(provider, conf.cacheSize, preSetIpList, server, family, conf.sni || conf.servername)","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/docmirror/dev-sidecar/blob/7710cd56cce760c708f30b01d2d4056eb8c402d5/packages/mitmproxy/src/lib/dns/index.js#L19-L55","documentation":"initDNS() parses each configured DNS provider to classify it as https/tls/tcp/udp. If a server string contains '://' but does not start with a recognized scheme (udp://, https://, tls://, dot://, tcp://), the library cannot infer the transport and throws immediately. This is a fail-fast guard against misconfigured DNS providers that would otherwise silently fail at query time.","triggerScenarios":"Calling initDNS/startup with config.dns.providers containing an entry whose server value has an unrecognized scheme, e.g. 'quic://dns.example.com', 'dns://1.1.1.1', or a typo like 'htps://dns.google'. Also thrown when a provider's 'type' field is absent and the server string cannot be classified.","commonSituations":"Users copy DNS provider entries from other tools (e.g. dnscrypt-proxy with 'sdns://' stamps or 'quic://' servers) into dev-sidecar config; typos in scheme names; hand-edited ~/.dev-sidecar/config.json overrides.","solutions":["Open ~/.dev-sidecar/config.json (or the merged running config) and find the dns.providers entry referenced in the message","Change the server scheme to a supported one: https://, tls:// (or dot://), tcp://, or udp:// (or a bare IP meaning udp)","For DoH/DoT providers only available over QUIC, pick their https/tls endpoint instead (e.g. use https://cloudflare-dns.com/dns-query)","If a custom type is intended, set the provider's explicit 'type' field to one of: https, tls, tcp, udp (whitespace is stripped and lowercased)"],"exampleFix":"// before\ndns: { providers: { custom: { server: 'quic://dns.adguard.com' } } }\n// after\ndns: { providers: { custom: { server: 'https://dns.adguard.com/dns-query', type: 'https' } } }","handlingStrategy":"validation","validationCode":"const SCHEMES = ['udp://', 'https://', 'tls://', 'dot://', 'tcp://']\nfunction isValidDnsServer(p) {\n  if (!p || !p.server) return false\n  const s = String(p.server)\n  if (p.type) return ['https', 'tls', 'tcp', 'udp'].includes(String(p.type).trim().toLowerCase())\n  if (!s.includes('://')) return true\n  return SCHEMES.some(pre => s.startsWith(pre))\n}\n// before startup: Object.entries(config.dns.providers).every(([k, p]) => isValidDnsServer(p))","typeGuard":"function hasKnownScheme(server) {\n  return typeof server === 'string' && (\n    !server.includes('://') ||\n    /^(udp|https|tls|dot|tcp):\\/\\//.test(server)\n  )\n}","tryCatchPattern":"try {\n  await DevSidecar.api.startup()\n} catch (e) {\n  if (String(e.message).startsWith('Unknown type DNS:')) {\n    console.error('Bad dns provider config:', e.message)\n    delete config.dns.providers.offending\n    await DevSidecar.api.startup()\n  } else throw e\n}","preventionTips":["Only use schemes udp://, https://, tls:// (dot://), tcp:// or bare IPs in dns.providers entries","Set an explicit type field when unsure of scheme inference","Validate ~/.dev-sidecar/config.json diffs after hand-editing","Test config changes with a config dry-run/merge before restart"],"tags":["dns","config","startup"],"backgroundTag":"unknown-dns-provider-type","analyzedSha":"7710cd56cce760c708f30b01d2d4056eb8c402d5","analyzedAt":"2026-08-31T22:07:07.234Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}