# Troubleshooting

- [Compiler errors](#compiler-errors)
- [Unexpected responses](#unexpected-responses)
- [Startup errors](#startup-errors)

## Compiler errors

**"`NewPost` doesn't describe itself to AI agents" (the trait `Schema` is not implemented)**

A repository's `Store` and `Update` types must derive `Schema`. Add `#[derive(Schema)]` under `#[laravel::input(..)]`:

```rust
#[laravel::input(fills = Post)]
#[validate(authenticated)]
#[derive(Schema)]
pub struct NewPost { /* .. */ }
```

**"`PublishPost` isn't an action or getter of `Post`" (the trait `CustomAction` is not implemented)**

The type has no `impl CustomAction<Post>`, or it implements it for another model than the repository's. See [Actions and getters](actions.md#writing-an-action).

**"type mismatch resolving `<PublishPostAction as CustomAction<Post>>::Target == Builder<Post>`"**

`Custom::index` or `Custom::standalone` was given an action on one model, or `Custom::show` one on the list. Use `Custom::show` for `type Target = Post`, and the other two for `type Target = Builder<Post>`. See [Actions and getters](actions.md#listing-them-in-the-repository).

**"Restify doesn't know how a `Status` looks in JSON" (the trait `Property` is not implemented)**

A field of a `#[derive(Schema)]` struct, or a value a `Field` shows, has a type Restify can't describe. Implement `restify::Property` for it, which says how the type is described and written. See [Writing](writing.md#field-types) and [Fields](fields.md#how-each-type-is-written).

**"no method named `without_mcp` found for struct `Restify`" (or `mcp`, `openapi`, `openapi_version`)**

The method belongs to a Cargo feature that is turned off. `mcp` and `without_mcp` need the `mcp` feature, and `openapi` and `openapi_version` need the `openapi` feature. Turn the feature on in `Cargo.toml`, or remove the call. See [Choosing features](installation.md#choosing-features).

**"serde doesn't know this `rename_all` rule"**

`#[derive(Schema)]` reads serde's own `rename_all` rules, such as `camelCase`, so check the spelling.

**"`..` isn't a gate" in `can_see`**

`can_see` takes a `bool`, or an async function from the request: `async fn is_admin(request: &Request) -> laravel::Result<bool>`. A function that also takes the model can't be a gate, because a gate runs once for a request. Use `Field::computed_with` for a value that depends on the model. See [Fields](fields.md#showing-a-field-to-some-users).

**"`NewPost` can't be the `Store` or `Update` input of a repository of `Post`" (the trait `Fills` is not implemented)**

The struct lacks `#[laravel::input(fills = Post)]`, names another model, or has a field whose type isn't `Clone`. The input fills the write and is then lent to the `creating` or `updating` hook, so it is cloned field by field.

**"method `creating` has 2 parameters but the declaration in trait has 3"**

`creating` and `updating` get the validated input as their second argument: `creating(create, input: &NewPost, request)`. See [Writing](writing.md#setting-columns-the-client-cant).

**"method `uri_key` has an incompatible type for trait"**

`uri_key` returns a `String`: `"articles".to_owned()`.

**The trait bound `Column<Post, String>: Relation<_>` is not satisfied, in `Related::raw` or `Related::through`**

Both take a relationship, such as `Post::user`, not a column such as `Post::title`. Declare the relationship on the model with `#[belongs_to]`, `#[has_many]` or another relationship attribute first. A `#[morph_to]` relationship isn't supported. See [Relationships](relationships.md).

**"type mismatch resolving `<.. as Relation<Post>>::Related == ..`", in `Related::through`**

The repository in `Related::through::<UserRepository>` must serve the relationship's model: `Post::user` holds a `User`, so it needs a repository whose `type Model = User`.

**"`HasMany<Comment>` isn't a relationship field holding `User` models"**

The closure of `Related::through` must return the field of the same relationship, such as `|post| &post.user` for `Post::user`. See [Relationships](relationships.md#declaring-the-relationships-clients-may-load).

**The `ValidatesRequest` trait is not implemented**

The input struct must say who may submit it: add `#[validate(authenticated)]` or `#[validate(anyone)]`.

**"... isn't a many-to-many relationship of `Team` to `Note`" (the trait `ManyRelation` is not implemented)**

`Related::many` only takes a `#[belongs_to_many]`, `#[morph_to_many]` or `#[morphed_by_many]` relationship. For any other kind, use `Related::through`. See [Relationships](relationships.md#many-to-many-relationships-clients-can-change).

**Errors inside the `laravel-rust-database` crate when building a package or a workspace**

The framework's `database` feature only compiles together with a driver. Enable `database-postgres`, `database-mysql` or `database-sqlite` on `laravel-rust` in the application.

## Unexpected responses

**Requests with a token, or creates and updates, get slow on SQLite when many come at once**

On SQLite, each write locks the whole database file, and other requests wait for it. Turn on SQLite's write-ahead log: add `journal_mode=wal` to `DATABASE_URL`, such as `sqlite://database/database.sqlite?mode=rwc&journal_mode=wal`. See [Many token requests on SQLite](sanctum.md#many-token-requests-on-sqlite).

**A deleted token still works for a while**

`SANCTUM_CACHE` is set, so the guard remembers accepted tokens for that many seconds. Delete a token with `AccessToken::delete`, which forgets it at once, or leave the setting out. See [Remembering tokens](sanctum.md#remembering-tokens).

**`429 Too Many Requests` from `POST /api/login`, `/api/register`, `/api/forgotPassword`, `/api/resetPassword` or `/api/verify/..`**

The client went over PHP's limits: 6 logins a minute for one email from one IP address, 30 logins a minute from one IP address, and 6 a minute from one IP address for each of the other routes. Wait for the seconds in the `Retry-After` header. See [Too many tries](authentication.md#too-many-tries).

**`POST /api/forgotPassword` answers `200`, but no email arrives**

Forgot password answers `200` whatever happens, so nobody can use it to find out who has an account. Check, in this order:

1. No user has that email. The answer is the same on purpose.
2. A reset email went to the same address less than a minute ago. A second one isn't sent.
3. The email couldn't be rendered or sent. The error is in the log. Turn on the framework's `minijinja` feature, which renders the email, and set its `MAIL_*` settings. See [Changing the emails](authentication.md#changing-the-emails).
4. The email waits in the queue. Run a queue worker, or set `QUEUE_CONNECTION=sync`.

**`422` "The url host is not allowed." from `POST /api/forgotPassword`**

The request sent its own `url`, and its host is neither the host of `RESTIFY_PASSWORD_RESET_URL` nor of `FRONTEND_APP_URL` (`APP_URL` when that is not set). Set `FRONTEND_APP_URL` to your frontend's address. See [Forgot and reset password](authentication.md#forgot-and-reset-password).

**`400` "Provided invalid token." from `POST /api/resetPassword`**

The token is wrong, was used already, or is older than 60 minutes. A newer reset email also replaces the token of the one before. Ask for a new link.

**A verification link sends the browser to `..?success=false&message=Invalid+or+expired+verification+link.`**

The link is older than 60 minutes, or was changed, or was signed with another `APP_KEY`. Links that PHP emailed only work while `APP_KEY` is the same as PHP's. The signature also covers the link's host, so the link must reach the server on the same host it names. See [Verifying emails](authentication.md#verifying-emails).

**Every request answers `400` with `Bad request.` in production, but works locally**

The request's `Host` is neither the host of `APP_URL` nor one of its subdomains. In production, Laravel for Rust refuses such a request before Restify sees it. The `local` and `testing` environments don't check. Laravel for PHP checks no host unless the application asks it to, so this often shows up right after a move from PHP. Set `APP_URL` to the address clients use, or list every host with `middleware.trust_hosts([..])` in `src/app.rs`. See [Trust every host your clients use](migrating-from-php.md#trust-every-host-your-clients-use).

**`422` with "`..` goes 4 relationships deep, and at most 3 are allowed" or "The request names 21 relationships"**

The `?related=` (or `include`) of the request goes deeper than `RESTIFY_RELATED_MAX_DEPTH` (3 by default), or names more relationships than `RESTIFY_RELATED_MAX_PATHS` (20 by default). Ask for the deeper ones in a second request, starting from the related repository, or raise the limit. See [How deep, and how many](relationships.md#how-deep-and-how-many).

**A relationship shows fewer rows than the database has, or `null`, or an attach answers `404` for a row that exists**

The related repository's `Repository::query` hides those rows from this request. A `through` relationship, and an attach, detach or sync, reach only the rows that the related repository's own endpoints reach. To show them, widen that `query` for the `Action` it gets. See [Who can see a relationship](relationships.md#who-can-see-a-relationship).

**A repository's middleware refuses an MCP tool, a nested route, the profile or the global search, not only its own routes**

A repository's `middleware()` runs wherever its operations are reached: its own routes, its MCP tools, a nested route of another repository, the profile, and the global search (`/api/restify/search` and the `global-search` tool) when the repository is globally searchable. A refusal answers with the middleware's status and `message`. In the global search, one repository's refusal refuses the whole search, as in Restify for PHP. Through MCP, a `403` shows its message, and other statuses show as an internal error. See [Where the middleware run](repositories.md#where-the-middleware-run).

**`DELETE /{repository}/{id}/field/{field}` answers `403` although the user may update the record**

The field's `can_update` refuses the user, or its `readonly_when` makes it read-only for them. Deleting a file writes the field, so it asks the same gates as a full update. See [Replacing and deleting files](files.md#replacing-and-deleting-files).

**Every request answers `403`**

The repository has no `authorize` method, or its `match` doesn't allow `Action::AllowRestify`, which every request is asked for first, or the action itself. Restify refuses everything by default. See [Authorization](authorization.md).

**`403` with `Unauthorized to view repository posts. Check "allowRestify" policy.`**

The repository's `authorize` refused `Action::AllowRestify`, which every request is asked for first. Allow it for the users who may use the repository. See [Authorization](authorization.md#deciding-who-may-do-what).

**A list has fewer rows than `per_page`, but `meta.total` counts more**

`authorize` refused `Action::Show` for some rows, so the list left them out after counting them, as Restify for PHP does. To leave them out of the count too, filter them in `Repository::query`. See [Authorization](authorization.md#rows-a-list-leaves-out).

**`404` with `Repository widgets not found.`**

The first part of the path names no repository, such as `/api/restify/widgets`. Check the repository's `uri_key` and that the provider registers it with `Restify::repository`. Restify for PHP answers this with a `500` `Server Error`, which is a PHP bug.

**`422` with `` `filters` must be a JSON list encoded in base64 ``**

`?filters=` isn't a JSON list encoded in base64. Build it with `btoa(JSON.stringify([{"key": "status", "value": "draft"}]))` in JavaScript, or `base64_encode(json_encode([...]))` in PHP. See [Advanced filters](filtering.md#advanced-filters). Restify for PHP answers this with a `500`, which is a PHP bug.

**Every request answers `401`**

The middleware given to `Restify::new().authenticate(..)` found no user. Check that the request sends `Authorization: Bearer <token>` and that the guard looks the token up the way it's stored. In a test, use `.acting_as(&user)`.

**`403` with `Unauthorized to use the route /api/restify/bulletins. Check prefix.`**

The repository has its own `prefix`, so it is served only under that path, such as `/api/v1/bulletins`. Send the request there. Restify for PHP answers the same. See [Repositories](repositories.md#serving-under-another-prefix).

**A public repository answers `500` to a guest**

On a public repository's list, show and getters no token is read, so `request.user()` fails in `authorize` or in a field's gate. Check `request.authenticated()` first and treat a guest as not allowed. See [Repositories](repositories.md#public-repositories).

**`401` with `Unauthorized to view restify.`**

The application's gate middleware refused the user, as Restify for PHP's `viewRestify` gate does. See [Authorization](authorization.md#refusing-some-users-everywhere).

**`POST /api/login` or `/api/register` answers `500`: "no session guard logs in `User`"**

These routes have no guard, because the client has no token yet. A field's `can_see` gate or a policy called `request.user()`, which fails on such a route. Check `request.authenticated()` first and treat a guest as not allowed. See [Authentication](authentication.md#fields-and-gates-on-guest-routes).

**`POST /api/logout` answers `200`, but the PHP application answered `500`**

This is on purpose. Restify for PHP deletes the token and then answers `500` "Server Error", which is a bug in PHP. Restify for Rust deletes the token and answers `200` with `{"message": "Successfully logged out."}`. See [Authentication](authentication.md#register-login-and-logout).

**`500`: "Sanctum has no settings"**

The Sanctum guard is used, or a login creates a token, but the guard isn't a provider. Add `providers.add(restify::auth::Sanctum::<User>::new())` in `src/app.rs`.

**`500`: "A Sanctum token can't be created for the User with key `..`"**

Sanctum's `tokenable_id` column holds integers, so a user model whose key is a UUID or text can't have Sanctum tokens.

**A deleted post still shows in `?related=posts`**

`soft_deletes` covers the repository's own queries, not relationships declared on other models. Add `filter = Post::deleted_at.is_null()` to the relationship. See [Soft deletes](soft-deletes.md#relationships-on-other-models).

**A filter or a sort has no effect**

The list ignores a parameter it doesn't know, as Restify for PHP does. Check that a field of the repository marks the column `matchable` or `sortable`, or that a scope has the name. The parameter is the column's name, not the field's `label`. A repository with no sortable field sorts by its key only under its table's name, such as `?sort=tags.id`. See [Filtering](filtering.md).

**A filter keeps no rows, or the wrong ones**

Each kind of match compares in its own way, as in Restify for PHP. A `Text` filter is an exact match, not "contains": use `?search=` for that. An `Integer` filter reads only the leading number, so `?votes=10,20` means 10; use `MatchKind::Array` for a list. A value that isn't of the column's type keeps no rows, such as `?author_id=-1` on a `u64` column. See [Filtering](filtering.md#filters).

**`422`: "The column [title] is not allowed for grouping"**

The column isn't marked `groupable`. Mark it with `Field::groupable()`, or `Field::query_only(..).groupable()` for a column no response shows. See [Grouping](filtering.md#grouping).

**An advanced filter is ignored**

Its `key` names no `Scope::advanced` filter of the repository, or the filter's `can_see` gate refuses the user. Check the names in `GET /api/restify/<uri-key>/filters`.

**"`PostRepository` isn't globally searchable" (the trait `GlobalSearch` is not implemented)**

`Restify::global_search::<R>()` needs `impl GlobalSearch for R {}`. Its items have defaults, so the empty block is enough. See [Global search](filtering.md#global-search).

**"`global_search` was called for the .. repository before `repository` served it"**

List the repository with `.repository::<R>()` first, then add it with `.global_search::<R>()`.

**`?related=` answers `200` but the relationship is missing**

A name the repository doesn't list is ignored, as in Restify for PHP. Check that `Repository::related` lists it and that the client uses the field's name. A `through` relationship is also left out when the related repository refuses `Action::AllowRestify` to the request, or when its `can_see` gate fails. For a nested name such as `comments.user`, the related repository must list `user`. See [Relationships](relationships.md).

**`403`: "You are not authorized to see the user relationship"**

The related repository refuses `Action::Show` for the one model a `through` relationship holds, such as a post's author. Allow it in that repository's `authorize`, or don't list the relationship. See [Relationships](relationships.md#who-can-see-a-relationship).

**`?search=` returns the whole list**

No field of the repository is `searchable`, so the term is ignored, as in Restify for PHP. `?search=0` is ignored too.

**A create ignores a field the client sent**

The `Store` struct doesn't declare the field, which is how mass assignment is prevented. Add the field if a client may write it, or set the column in `creating` if the server decides it. See [Writing](writing.md).

**A `PATCH` clears columns the request didn't send**

A field of the `Update` struct is an `Option<T>`. Declare it as `Sometimes<T>`, or `Sometimes<Option<T>>` when `null` may clear it.

**A resource has no attributes, or lacks a column**

A response shows only the fields `Repository::fields` lists. Add `Field::new(Post::column)`. A field with `hide_from_index` is left out of lists and of the answers to a create or an update, and a field with `can_see` is left out for the requests that don't pass its gate. See [Fields](fields.md).

**A column shows up in responses that shouldn't**

Remove its field from `Repository::fields`, or keep it for filtering with `Field::query_only`. To show it to some users only, give the field a `can_see`. A relationship declared with `Related::raw` is different: it shows the related model as serde writes it, so there `#[serde(skip)]` on the model's field hides a column. Use `Related::through` to show the related repository's fields instead. See [Relationships](relationships.md#raw-relationships-and-the-models-json).

**`403` from `/posts/bulk`**

The repository's `authorize` doesn't allow `Action::StoreBulk`, `Action::UpdateBulk` or `Action::DeleteBulk`. They are separate from the single actions. See [Bulk operations](bulk.md#allowing-bulk-requests).

**`perPage` returns more rows than you want to allow**

A request may ask for any page size unless the application sets `RESTIFY_MAX_PER_PAGE`. See [Filtering](filtering.md#pagination).

**`422` from a bulk request: "Send at most 100 items at once"**

The array holds more than the repository's `MAX_BULK` items. Split the request, or raise `MAX_BULK`.

**`422` from a bulk request: "Send the items as a JSON array." or "Send at least one item."**

The body of a bulk request is a JSON array with at least one item, not an object. See [Bulk operations](bulk.md).

**`422` from a bulk update: "The 0.title field is required."**

A bulk update is a full update, like `PUT`: every field with a `required` rule must be in every item. Send the field in each item, or use `PATCH` on each record to change only some fields.

**A bulk request saved nothing**

That is on purpose: Restify checks every item before it writes any, and one failed item stops them all. A field error names the item to fix by its position, starting at `0`, such as `1.title`.

**`422` from `PUT`: "A post needs a title." though only `votes` was sent**

`PUT` and `POST /api/restify/posts/1` are full updates, so every field with a `required` rule must be sent. Use `PATCH` to change only the fields you send. See [Writing](writing.md#the-update-input).

**A field sent in a create or an update was not saved**

A write gate refused it: `can_store`, `can_update`, `can_patch` or `readonly_when`. The request still succeeds, without that field. See [Writing](writing.md#fields-only-some-users-may-write). Note that `can_update` isn't asked by `PATCH`.

**"The posts field `featured` has a write gate, so Restify removes `featured` from the input of a request the gate refuses, but `app::models::NewPost` requires `featured`"**

The application refuses to start. A field with a write gate is removed from the input when the gate refuses, so the input struct must allow it to be missing. Declare the field as `Sometimes<T>`, such as `pub featured: Sometimes<bool>`.

**An action answers `404` "Action not found." (or a getter "Getter not found.")**

The request names no action listed where it was sent. Check three things. The key: `?action=` must be the action's `uri_key`, which defaults to its `NAME` in kebab-case, such as `publish-posts-action`. The place: an action listed with `Custom::show` runs at `/posts/{id}/actions`, and one listed with `Custom::index` at `/posts/actions`. The method: an action answers `POST` and a getter `GET`. `GET /api/restify/posts/actions` lists what a request may run. The message is PHP's, so it doesn't say which keys exist.

**An action answers `403` "Not authorized to run this action."**

Its `can_run` refused, or it has none, which refuses everyone by default. For an action on the list, one refused post refuses the whole request. See [Actions and getters](actions.md#who-may-see-and-run-one).

**An action answers `403` "You don't have permission to run this action."**

Its `can_see` hides it from this request.

**An action answers `422` "The repositories field is required."**

An action listed with `Custom::index` runs on the posts the client names: send `{ "repositories": [1, 2] }` or `{ "repositories": "all" }`. For an action that runs on no post in particular, list it with `Custom::standalone`.

**A model answers `404` although it exists**

`Repository::query` leaves it out, or the key in the URL isn't of the key's type.

**The MCP server answers `406` or `415`**

The request isn't one the MCP specification allows. A client must send `Accept: application/json, text/event-stream` (`406` without it) and `Content-Type: application/json` (`415` without it). MCP clients do this for you. In a test, `.json(..)` sets `Accept` to `application/json` only, so add the header after it, as [Testing](testing.md#testing-mcp-tools) shows.

**The MCP server answers `403` with "The request's origin isn't allowed."**

The request came from a browser page on another origin, such as a frontend on `http://localhost:5173` calling an API on `http://localhost:8000`. List that origin in `src/config/cors.rs`, and add the server's path, such as `mcp/*`, to its `paths`. `Allowed::Any` doesn't count: name each origin. See [Calling the MCP server from a browser](mcp.md#calling-the-mcp-server-from-a-browser).

**`POST /teams/1/attach/users` answers `400` with "Missing BelongsToMany or MorphToMany related for [users]"**

Three things cause it:

- The team repository's `related` doesn't list `users` with `Related::many`. `Related::through` shows a relationship but doesn't let clients change it.
- The related repository's `authorize` refuses `Action::AllowRestify` for this request.
- The relationship's `can_see` refuses this request.

See [Relationships](relationships.md#attach-detach-and-sync).

**An attach, detach or sync answers `403`**

The parent's `authorize` refused `Action::Attach`, `Action::Detach` or `Action::Sync` with the relationship's name, such as `Action::Attach("users")`. A `match` that doesn't list the question refuses it. To decide for each related model, read `restify::relating::<User>(request)`. See [Relationships](relationships.md#who-may-attach-detach-and-sync).

**`GET /posts/1/comments` answers `403` with "Eager field missing from the parent [posts] related fields."**

The last part of the URL must be the related repository's name, such as `comments`, and the parent's repository must list that relationship with `Related::through` or `Related::many`. A `Related::raw` relationship has no nested routes. The same answer comes when the related repository refuses `Action::AllowRestify`, or the relationship's `can_see` refuses. See [Relationships](relationships.md#nested-routes).

**`POST /teams/1/users` answers `400` with "Creating [users] through [teams] is only supported for has-one and has-many relations"**

A create through a parent only works for `#[has_one]`, `#[has_many]`, `#[morph_one]` and `#[morph_many]`. To add an existing user to a team, use `POST /teams/1/attach/users`. A has-many relationship also answers this when the related model doesn't declare the `#[belongs_to]` back to the parent.

**An agent doesn't see a field, or sends the wrong thing**

Look at what the agent sees: `tools/list` on the MCP server in `direct` mode, or `get-operation-details` in `wrapper` mode, or the test in [Testing](testing.md#testing-mcp-tools). A field needs a doc comment to have a description, and a rule needs to be a `#[validate(..)]` attribute to appear in the schema.

**The MCP server lists only five tools**

That is `wrapper` mode, the default: `global-search` and four tools that find and run the operations. The agent finds each repository's operations with `discover-repositories`, then runs them with `execute-operation`. To list one tool per operation instead, set `RESTIFY_MCP_MODE=direct`. See [Choosing a mode](mcp.md#choosing-a-mode).

**`global-search` finds nothing, or leaves out a repository**

The tool searches only the repositories added with `.global_search::<R>()`, the same ones `GET /search` searches. A repository's `const MCP` doesn't matter here. Add the repository after `.repository::<R>()`. See [Global search](filtering.md#global-search).

**An agent gets `Tool [posts-store-tool] not found.`, or `INVALID_REPOSITORY` or `INVALID_OPERATION`**

The server doesn't serve that operation to this user. When the message starts with `Unknown operation_type` or `Unknown action` (or `Unknown getter`), it lists the valid names: use one of them. Otherwise, check, in this order:

1. The repository sets `const MCP`. Without it, the repository has no tools.
2. `const MCP` allows the operation, such as `store: true`. `McpTools::INDEX` allows the list only.
3. `RESTIFY_MCP_READ_ONLY` isn't `true`. Read-only mode drops every tool that writes, and every action.
4. For an action or getter, its `can_see` allows this user.
5. The tool name fits the mode: `posts-store-tool` exists in `direct` mode only. In `wrapper` mode, call `execute-operation`.

See [Letting agents use a repository](mcp.md#letting-agents-use-a-repository).

**An action run through MCP changes no record**

The tool reads the records from `repositories`, not from the `resources` its schema lists, as in Restify for PHP. Send `{ "repositories": [1, 2] }`. See [Behaviour kept from Restify for PHP](mcp.md#behaviour-kept-from-restify-for-php).

**A relationship is missing from what an MCP tool returns**

The related repository doesn't set `const MCP`. A tool leaves out the relationships of repositories that agents may not use. Set `const MCP` on that repository, even to `Some(McpTools::INDEX)`.

**A file was sent, but the column didn't change**

Check these, in order:

- The request was a `PATCH`. `PATCH` reads a JSON body only, as in Restify for PHP. Send the file with `PUT`, or `POST /api/restify/{repository}/{id}`.
- The body wasn't `multipart/form-data`. Only that body can hold a file.
- The input struct has no `UploadedFile` field named like the column, or the repository lists the column with `Field::new` instead of `Field::file`. See [Files and images](files.md#declaring-a-file-field).
- The request was a bulk request. Bulk requests ignore file fields, as in Restify for PHP.

**`422` with "The avatar field is invalid." on a file field**

The client sent text, such as a URL, instead of a file. A file field takes a file in a `multipart/form-data` body. To store URLs, add a plain text field with the `url` rule. A field with a rule answers with that rule's message instead, such as "The cover field must be an image." for `#[validate(image)]`.

An MCP tool call that names a file field gets the same answer. Tool arguments are JSON, which can't hold a file, so the tools don't list file fields. Upload the file with an HTTP request instead. See [Files and images](files.md#ai-agents-and-bulk-requests).

**`404` with an empty message from `DELETE /api/restify/{repository}/{id}/field/{field}`**

The field isn't a file field of the repository, or it is `.deletable(false)`. The name in the path is the column's name, such as `avatar`.

## Startup errors

**"The documents field `title` calls `path`, which only a file field has"**

`disk`, `path`, `store_as`, `store_original_name`, `store_size`, `prunable`, `deletable` and `url` only work on a field made with `Field::file` or `Field::image`. Change `Field::new` to one of them, or remove the call.

**"The `users` relationship can't show the pivot `role`"**

`Related::pivot` needs a relationship declared with `Related::many`, and the field's type must name the join row that has the column, such as `BelongsToMany<User, TeamUser>`, not `BelongsToMany<User>`. See [Relationships](relationships.md#many-to-many-relationships-clients-can-change).

**"Two Restify repositories are both named `posts`"**

Two repositories serve models with the same table, or return the same `uri_key`. Override `uri_key` on one of them.

**"The posts action `Publish Posts` needs a kebab-case key"** or **"has two actions with the key `publish`"**

Change the `CustomAction::uri_key` or the `NAME` the message names. A key is lowercase letters, digits and dashes, unique among the repository's actions, and among its getters.

**"The posts repository shows two fields named `title`"**

Two fields of one view have the same name. Remove one from `Repository::fields`, or rename one with `Field::label`.

**"The posts field `excerpt` is computed, so clients can't search, filter, sort or group by it"**

A computed field has no column to query. Remove `searchable`, `matchable`, `sortable` and `groupable` from it, or write a [scope](filtering.md#scopes).

**"The posts field `status` is `matchable`, but its column's type doesn't say how to compare it"**

**"The posts field `status` is `matchable_as(MatchKind::Text)`, but its column's type can't read a filter's value"**

The column's type has no `Property::parse`, so no filter value could ever equal a row. Set `Property::MATCH` and `Property::parse` for the type, or filter with a `Scope::matching` in `Repository::scopes`. Every integer type, `u64` keys included, `String`, `Uuid`, `Ulid`, the floats, `Decimal`, `bool`, `Timestamp` and `civil::Date` already can be read. See [Filtering](filtering.md#filters).

**"The posts getter `stats` takes input"**

A getter answers `GET`, which has no body to send input in. Set its `type Input = restify::NoInput`, or list it in `actions` instead.

**A test on SQLite fails at random, before its first line, with "the SQLite database is locked by another connection's write" and `SQL: DELETE FROM refreshed_database`**

The test started while the test before it was still closing its connection to the same test database. The cause is in `laravel-rust` (0.1.6 and 0.2.0), not in your test. Make each new test connection wait for the old one, as [Testing on SQLite](testing.md#testing-on-sqlite) shows.

## Import errors

`restify:import` checks the whole manifest before it writes anything. Each of these errors means nothing was written.

**"The manifest has names that give no Rust name, or the same one"**

A name in the manifest can't become a Rust name. Either it has no ASCII letter or digit, such as a column called `--`, or two names turn into the same one. Examples: two models called `Post` in different namespaces, or the columns `first-name` and `first_name`. The error lists each one. Rename it in the PHP application, then export again with `php artisan restify:export`.

**"The import would write `…`, which isn't a plain path inside the application"**

A path the import built points outside the application's folder. That only happens when the manifest was edited by hand. Export it again, and don't edit it.

**"Nothing was written: … The application's files are as they were before the import"**

A file couldn't be written, for example because a folder is read-only, or a folder has the same name as a file the import writes. The import put back every file it had already changed. Fix the cause and run the import again.

**"The manifest's `app.sanctum.expiration` is … which isn't a number of minutes"**

Sanctum's token lifetime, `config('sanctum.expiration')`, must be a number of minutes, or `null` for tokens that don't expire. Fix it in the PHP application, then export again.
