# List CODEOWNERS errors

> Check a repository's CODEOWNERS file as a linter would. g1t reads it from one branch (ref, the default branch unless you say): the first of .g1t/CODEOWNERS, .github/CODEOWNERS, CODEOWNERS, docs/CODEOWNERS and .gitlab/CODEOWNERS that exists.

<div class="g1t-endpoint"><span class="g1t-method" data-method="get">GET</span><code>/repos/{owner}/{name}/codeowners/errors</code></div>

Returns its `path` (null when there is none), the `ref` read, its `size`, how many `rules` it has, its `sections`, and `errors`: each with its `line` (0 for the file as a whole), `kind`, the `token` at fault and a `message` saying how to fix it. `kind` is `too_large`, `negation`, `character_range`, `bad_pattern`, `bad_owner`, `bad_section`, `unknown_user`, `unknown_team`, `unknown_email`, `no_write_access` or `team_no_access`. Needs the Read role; a public repository's is open to anyone.

The file is the first of `.g1t/CODEOWNERS`, `.github/CODEOWNERS`, `CODEOWNERS`, `docs/CODEOWNERS` and `.gitlab/CODEOWNERS` found on `ref` (the default branch when left out); `path` is null when there is none, with no errors. Each error has its `line` (0 for the file as a whole), the `token` at fault, a `message`, and a `kind`:

| `kind` | |
| --- | --- |
| `too_large` | The file is over 3 MB and was ignored. |
| `negation` | A pattern starting with `!`; the line was skipped. |
| `character_range` | A pattern with `[` or `]`; the line was skipped. |
| `bad_pattern` | A pattern that names no path; the line was skipped. |
| `bad_owner` | An owner that is not `@user`, `@workspace/team` or an email address. |
| `bad_section` | A section header that could not be read. |
| `unknown_user` | No account has that username. |
| `unknown_team` | The workspace has no team of that slug. |
| `unknown_email` | No account has confirmed that address. |
| `no_write_access` | The person cannot write to the repository. |
| `team_no_access` | The team has no write access to the repository. |

See [Code owners](/guides/codeowners/).

- **Authentication:** Optional. Public data can be read without a token; send one to see what is private.
- **MCP tool:** [`repository`](/reference/mcp/#repository) with `action` `codeowners`, and the same inputs
- **Scope:** An access token needs [`repo:read`](/guides/authentication/#scopes).

## Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `owner` | string | Yes | The workspace that owns the repository. |
| `name` | string | Yes | The repository's name. |

## Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `ref` | string | No | The branch, tag or commit to read the file from. The default branch if left out. |

## Example request

```sh
curl "https://api.g1t.sh/repos/flagon-io/hello/codeowners/errors?ref=main" \
  -H "Authorization: Bearer $G1T_TOKEN"
```

## Example response

A successful request answers `200` with:

```json
{
  "path": ".github/CODEOWNERS",
  "ref": "main",
  "size": 412,
  "rules": 9,
  "sections": [
    "Docs"
  ],
  "errors": [
    {
      "line": 4,
      "kind": "unknown_team",
      "token": "@flagon-io/platform",
      "message": "@flagon-io/platform is not a team of flagon-io."
    },
    {
      "line": 7,
      "kind": "negation",
      "token": "!docs/internal/",
      "message": "!docs/internal/ starts with !, and negation is not supported; this line is skipped. Give the path a later rule with no owners instead."
    }
  ]
}
```

## Errors

A failed request answers with one of these statuses and a body like `{"error": {"code": "not_found", "message": "Repository not found."}}`. See [errors](/reference/api/#errors).

| Status | Code | When |
| --- | --- | --- |
| 401 | `unauthenticated` | A token is required, or the one sent is not valid. |
| 403 | `forbidden` | The token is valid but not allowed to do this, such as a member-only change or an agent token outside its repository. |
| 404 | `not_found` | It does not exist, or you cannot see it. |
| 422 | `invalid` | The input is not valid. `message` says which field and why. |
