# Map errors

A map fails only when no source answered. One source failing is a warning.

## Two levels

- **The request.** A request that is not valid, cannot be paid for, or that no source could answer fails with an HTTP error and the one [error shape](https://millionshort.com/docs/errors#the-error-shape) every endpoint uses. It costs nothing.
- **Each source.** When at least one source answered, the call is a `200`. A source that could not be read is a warning, and its URLs are missing.

## Request errors

| Status and code | When | Try next |
|---|---|---|
| `400 INVALID_PARAM` | A field the API does not take, a `limit` over 5,000, an unknown source, a pattern that is not a valid regular expression | Fix the request |
| `400 INVALID_PARAM`, with `details.reason` `URL_NOT_ALLOWED` | The URL is not a public web page we will fetch: an address, another port, credentials in the URL | |
| `401 AUTH_MISSING_KEY`, `401 AUTH_INVALID_KEY` | No `Authorization` header, or a key that is malformed, revoked or expired | |
| `403 ROBOTS_DISALLOWED` | The site's robots.txt closes it to our bot, or the site asked us not to fetch or serve it (`details.reason` is then `SITE_OPTED_OUT`). Our index is not used either | Nothing: this is final |
| `429 INSUFFICIENT_CREDITS` | The balance does not cover `limit` URLs | A smaller `limit` |
| `429 RATE_LIMITED` | Your plan's requests a minute; or, with `details.reason`, the site is busy for us (`HOST_BUSY`) or your team reached its daily limit for the site (`HOST_DAILY_LIMIT`) | After `retry_after_seconds` |
| `502 FETCH_FAILED` | No source answered: the site did not answer usefully, or its robots.txt could not be read, so nothing was fetched | Later |
| `502 FETCH_BLOCKED_BOT` | No source answered, and the site refused our bot | |
| `504 FETCH_TIMEOUT` | The site was too slow | Later |

The `429` with a `details.reason`, the two `502`s and the `504` happen only when every source you asked for failed. Keep `index` among the sources, beside `sitemap` or `links`, and a slow site still gets an answer from what we hold. A site whose robots.txt closes it to us is refused whatever the sources: asked for the index alone, we read the site's robots.txt first, and nothing else. When that robots.txt cannot be read, an index-only call is a `502 FETCH_FAILED`.

## A source that failed

```text
"warnings": [
  {
    "code": "source_unavailable",
    "source": "sitemap",
    "reason": "ROBOTS_UNAVAILABLE",
    "message": "The \"sitemap\" source could not be read for this call, so its URLs are missing."
  }
]
```

`reason` is one of the [per-URL codes of Extract](https://millionshort.com/docs/extract/errors#per-url-errors):

| Reason | Meaning | Try next |
|---|---|---|
| `ROBOTS_UNAVAILABLE` | robots.txt could not be read, so we did not fetch | Later |
| `HOST_BUSY` | We are already fetching from this site as fast as we allow | In a few seconds |
| `HOST_DAILY_LIMIT` | Your team reached its daily limit for this site | Tomorrow (UTC) |
| `BLOCKED_BY_SITE` | The site refused our bot | |
| `TIMEOUT` | The site was too slow, or the call had no time left for this source (a map answers within about 25 seconds) | Later, or ask for that source alone with `sources` |
| `FETCH_FAILED` | The source did not answer usefully. For `index`: our index could not be asked | Later |

A site with no sitemap is not a failure. The `sitemap` source answers with no URLs and there is no warning.

## What not to work around

`403 ROBOTS_DISALLOWED` is final. There is no option to ignore robots.txt, and no source gets past a site's own choice.

## `truncated` is not an error

`summary.truncated: true` says the site has more URLs than you were given. Raise `limit`, or narrow the list with `include` or `search`.
