# `type.auth_principal_construction`

Caller is made from a record outside tests, fixtures and seeds.

Area 8, [Identity](../topics/identity.md); not declinable; the next step is usually the agent's.

A caller only comes from signing in; tests, fixtures and seeds make one
from a record:

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

type Handle = Text {
    max_length: 40
}

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

action act_as(member: Member) -> Principal.user {
    return Principal.user(member)
}
```

```text
error: An action can't make a caller
 --> main.jadpo:19:12
   |
19 |     return Principal.user(member)
   |            ^^^^^^^^^^^^^^ made from a record
  reason: A caller only comes from signing in; tests, fixtures and seeds make one from a record with `Principal.user(...)`, and application code takes it as a parameter a route passes.
  next: Take a `Principal.user` parameter, which the route passes as `current_principal.user` (agent)
  rule: type.auth_principal_construction
  help: https://jadpo.dev/docs/errors/type.auth_principal_construction

check failed: 1 error, 1 file
```
