# PAC file does not parse

Source: https://findproxyforurl.net/rules/syntax-error/ · last updated 2026-10-11

Rule PAC-E001 (`syntax-error`), severity critical, category: Errors and robustness.

The file is not valid JavaScript. No engine can run it; every browser falls back to its no-PAC behaviour, which in practice is DIRECT.

## Why it matters

A PAC file is a JavaScript program. If it does not parse, no engine ever gets to call
`FindProxyForURL`, and the client behaves as if no proxy were configured. In Chromium the
failed script is logged and connections go direct unless the `ProxyPacMandatory` policy is
set. For an enterprise that relies on the proxy for inspection and logging this is the
worst possible outcome: every request bypasses the proxy and nobody is told.

Typical causes: a missing brace or quote, a copy-paste accident, smart quotes from a word
processor (see PAC-E014), ES2015 syntax on an ES5 engine (see PAC-K001, reported
separately because it parses in modern browsers).


## How to fix

Fix the reported syntax error; run the file through a JavaScript parser (ES5 mode) before deploying.

## Bad

```js
function FindProxyForURL(url, host) {
  if (isPlainHostName(host)) {
    return "DIRECT";

  return "PROXY proxy.corp.example:8080";
}
```

## Good

```js
function FindProxyForURL(url, host) {
  if (isPlainHostName(host)) {
    return "DIRECT";
  }
  return "PROXY proxy.corp.example:8080";
}
```

## Engine behaviour

- chromium: Script load fails; requests go DIRECT unless the ProxyPacMandatory policy is set. (source: doc, verified 2026-10-04)
- winhttp: A file that does not compile gives the calling program an error instead of a proxy list; what happens next depends on the program. (source: lab, verified 2026-10-11)
