# `policy.lookup_unchecked`

An action looks a person up by email with no permission check of its own before it: it isn't listed under `actions:`, its line names `Access.public`, or its line can't be checked before the lookup.

Area 9, [Policy](/docs/policy.md); not declinable; the next step is usually the human's.

## Why Jadpo refuses it

`<Entity>.lookup(email: address)` finds a person whoever may read their
record, and whether it finds one tells the caller whether the address
has an account. So it runs only behind its action's own line under root
`policy { actions: }`, which says who may look people up, checked as the
action starts:

- anyone signed in, or a role held across the whole application;
- or a role held in a record, such as `WorkspaceRole.owner`, checked in
  the record whose `id` the action is given as its one parameter of
  that type.

An action that isn't listed, a line naming `Access.public`, and a line
naming only who a record the action hasn't found yet decides, such as
`Todo.owner_id`, leave nothing to check before the lookup.

## What it looks like

main.jadpo:

```jadpo
principal {
    user: {
        subject: Member.handle
    }
}

authentication {
    api_token: {}
}

type Handle = Text {
    max_length: 40
}

type AddressStanding = Enum {
    account_held
    no_account
}

entity Member {
    id: Uuid
    handle: Handle {
        unique: true
    }
    email: Email {
        unique: true
    }

    policy: {
        create: [Access.public]
        read: [id]
    }
}

/// Whether an address has an account.
action has_account(email: Member.email) -> AddressStanding {
    match Member.lookup(email: email) {
        none -> {
            return AddressStanding.no_account
        }
        some -> {
            return AddressStanding.account_held
        }
    }
}
```

```text
error: `has_account` looks a `Member` up by email with no permission check before it
 --> main.jadpo:37:11
   |
37 |     match Member.lookup(email: email) {
   |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^ no permission check of its own
  reason: `Member.lookup` finds a person by their exact address whoever may read `Member`, so it runs only behind its action's own line under root `policy { actions: }`, which says who may look people up. `has_account` isn't listed.
  next: List `has_account` under `policy { actions: }` with who may look people up, such as `[<Role>.owner]` (human)
  rule: policy.lookup_unchecked
  help: https://jadpo.dev/docs/errors/policy.lookup_unchecked

check failed: 1 error, 1 file
```

`(human)` at the end of the `next:` line tells your coding agent to stop
and ask you which fix you want, because the choice is yours to make: it
decides who may learn whether an address has an account.

## How to fix it

**If anyone signed in may look people up**, list the action for them:

```jadpo
policy {
    actions: {
        has_account: [Access.authenticated]
    }
}
```


Only someone signed in now reaches the lookup.

## Related

- [Permissions on actions](/docs/action-permissions.md)
- [`type.lookup_context`](/docs/errors/type.lookup_context.md)
