# Upgrade Cargo Dependencies Weekly for an Actix Web API

Yes. Each week the agent bumps the crates by group, runs clippy, the tests and the Postman suite against Postgres, and opens one PR, or stops and says why.

[Run this on Rush](https://cloud.getrush.ai/run/upgrade-cargo-dependencies/actix/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent reads what the API depends on and how it is checked before it bumps anything. In an API laid out like snamiki1212/realworld-v1-rust-actix-web-diesel, `Cargo.toml` names fourteen direct dependencies with caret ranges: `actix-web` 4.3, `actix-cors` 0.6.4, `diesel` 2.1.0 with the `r2d2`, `postgres`, `chrono`, `uuid` and `serde_json` features, `jsonwebtoken` 8.3, `bcrypt` 0.14.0, `env_logger` 0.10.0, `log`, `serde`, `serde_json`, `chrono`, `anyhow`, `thiserror` 1.0, `futures`, `convert_case` and `uuid` 1.3.3 with `v4`. `Cargo.lock` is lockfile version 3 with 213 packages and resolves those to `actix-web` 4.3.1, `diesel` 2.1.0, `jsonwebtoken` 8.3.0, `bcrypt` 0.14.0, `env_logger` 0.10.1 and `uuid` 1.6.1. `.github/workflows/ci.yml` has three jobs: `cargo clippy -- -D warnings` on the stable toolchain, `cargo build --verbose` and `cargo test --verbose`, and an end-to-end job that starts a `postgres` service, runs `cargo run` in the background, waits on port 8080 with `scripts/wait-for-it.sh`, runs `diesel setup` with a `diesel_cli` it installs, and then `e2e/run-api-tests.sh`, which runs the RealWorld Postman collection through `npx newman` against `APIURL`.

Then it reads where each crate is used, because that is what decides whether a major bump is safe. `src/utils/token.rs` calls `jsonwebtoken::encode` and `decode` with `Validation::default()` and a `Claims` struct carrying `exp`, `iat` and `user_id`; `src/utils/hasher.rs` wraps `bcrypt::hash` with `DEFAULT_COST` and re-exports `verify`; `src/error.rs` converts `diesel::result::Error`, `r2d2::PoolError`, `BcryptError`, `JwtError` by `ErrorKind` and `uuid::Error` into one `AppError` that implements `ResponseError`; `src/app/drivers/middlewares/auth.rs` is a hand-written `Transform` and `Service` pair over `ServiceRequest` with `EitherBody`; and `cors.rs` builds `actix_cors::Cors` with `allowed_origin_fn`. Only two modules carry `#[cfg(test)]` blocks, `converter.rs` and `auth.rs`, so `cargo test` proves little on its own and the Postman suite is the real check.

The agent upgrades in groups, one commit each, so a reviewer can drop one without losing the rest. Patch and minor bumps inside the existing ranges come first with `cargo update`; then each major bump gets its own commit with the code change it needs: `env_logger` and `jsonwebtoken` are read from their changelogs for renamed `Validation` fields or a changed `DecodingKey` constructor, `bcrypt` for a changed error type that `error.rs` matches on, `thiserror` 2 for the derive attribute syntax, and `actix-cors` for the builder methods `cors.rs` calls. `diesel` is bumped only within 2.x unless the prompt says otherwise, because a major there means regenerating `src/schema.rs` and touching every repository module. The `Dockerfile` pins `rust:1.74-slim`, and a crate whose minimum supported Rust version passes that is either held back or the image is bumped in the same commit, with the reason written down.

For each group it runs `cargo clippy -- -D warnings` and `cargo build`, then starts a Postgres in the sandbox, copies `.env.example` to `.env` as `scripts/copy-env.sh` does, installs `diesel_cli` for Postgres, runs `diesel setup` to apply the eight migrations under `migrations/`, starts the server, and runs `e2e/run-api-tests.sh` with `APIURL=http://localhost:8080/api`. A group whose clippy, build or Postman run fails is dropped and its error quoted in the pull request; the ones that pass go in. The pull request lists each crate's old and new version, the code it changed for a major, and the final Postman summary.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Upgrade this Actix Web API's Cargo dependencies. Read Cargo.toml, Cargo.lock, .github/workflows/ci.yml, Dockerfile, scripts/copy-env.sh, e2e/run-api-tests.sh, src/error.rs, src/utils/token.rs, src/utils/hasher.rs and src/app/drivers/middlewares/ first. Start with `cargo update` for patch and minor bumps within the current ranges, then take each major bump as its own commit with the code change its changelog requires; keep diesel within 2.x and say which crates you held back and why, including any whose minimum Rust version passes the Dockerfile's toolchain. After each group run `cargo clippy -- -D warnings`, `cargo build` and `cargo test`, then start Postgres in the sandbox, copy .env.example to .env, install diesel_cli with the postgres feature, run `diesel setup`, run the server and run e2e/run-api-tests.sh against it. Drop any group that fails and quote the failure. Open one pull request that lists every crate's old and new version, the code changed for each major, and the final Postman summary. If no group passes, open no pull request and say why.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

What comes back is one pull request on its own branch with one commit per group: the `cargo update` sweep of `Cargo.lock`, then a commit per major bump that changes `Cargo.toml`, the lock file and the one or two source files that crate touches, such as `src/error.rs` for a changed error enum or `src/utils/token.rs` for a renamed validation field. The description is a table of crate, old version, new version and the commit that carries it, followed by the crates held back with the reason for each, the clippy and build results per group, and the Postman run's passed and failed counts from `newman`.

The session keeps the record: each `cargo` command with its full output, the changelog pages the agent read for the majors, the Postgres and `diesel setup` logs, the server's startup output and the full `newman` report. `GET /o/{org}/sessions/{id}/messages` returns that transcript, and `GET /o/{org}/p/{project}/sessions/{id}/changes` returns the diff per commit's files.

Before merging, a reviewer reads the code changes behind each major, since a renamed field compiles either way but a changed default, such as a validation that now rejects a missing `aud` claim, only shows in behaviour. They check that `diesel` stayed within 2.x unless they asked otherwise and that the Dockerfile's toolchain still builds the result. A group they want out is one `git revert` of its commit.

## Run it on every Monday morning

Create an automation in the Project with this prompt and a `schedule` trigger (`cron` `0 9 * * 1` in your `timezone`). After the first run catches the API up, each week's run opens one pull request with that week's bumps, or none when nothing moved. Because each group is its own commit, dropping a bump before merge is a revert of one commit.

To have the link reach your server, start the weekly run from your own scheduler instead, with `POST /o/{org}/sessions` and an API key that has a webhook URL: Rush then POSTs `run.completed` with the `session_url` when the turn ends, and a handler on your side can post the pull request link where the API's maintainers read. A run that ends with no safe group opens no pull request and says why in its result.

## Why run it on Rush?

A Rust API falls behind because every major bump is an afternoon: read the changelog, fix the compile errors, find a Postgres, run the Postman suite, and only then learn that `jsonwebtoken` changed a default. In a Rush sandbox the agent does that afternoon for every crate at once, with the same clippy flags, the same migrations and the same Postman collection the repository's CI uses, and nothing is installed on anyone's machine.

The pull request carries its proof: the per-group clippy and build results, the `newman` summary and the transcript of every command. Several APIs can be upgraded on the same Monday in separate sandboxes, each with its own Postgres, and a reviewer who disagrees with one bump reverts one commit rather than reopening the whole week.

## Frequently asked questions

### Will it upgrade diesel to a new major?

Not unless you say so. A diesel major means regenerating `src/schema.rs` with `diesel print_schema` and touching every `repositories.rs`, which is a migration rather than a weekly bump. The agent takes diesel's patch and minor releases within 2.x, lists the newer major as held back, and a prompt that asks for it gets a separate run.

### What if a crate needs a newer Rust than the Dockerfile has?

The Dockerfile pins `rust:1.74-slim`, so the agent checks each crate's minimum supported Rust version against it. A crate past that is held back and named, with the toolchain bump it would need; if the prompt allows a toolchain bump, the agent changes the Dockerfile's tag in the same commit as the crate and says so.

### Does it run the Postman suite?

Yes, the same way `ci.yml`'s end-to-end job does: a Postgres in the sandbox, `.env` from `.env.example`, `diesel setup` for the migrations, the server on port 8080, and `e2e/run-api-tests.sh` through `npx newman`. The summary with passed and failed requests goes in the pull request, and a group that breaks a request is dropped rather than merged.

### What happens when only two of the twelve direct crates have moved?

The run opens a small pull request with those two, or one `cargo update` commit when they are patch releases. When nothing has moved since the last run it opens nothing and says so in its result, which the key's webhook or the automation's run list shows.

## More Actix Web jobs

- [Write Tests for an Actix Web API](https://getrush.ai/run/write-actix-tests/actix/)
- [Add Response Compression to an Actix Web App from a Linear Issue](https://getrush.ai/run/add-compression/actix/)
- [Add CORS to an Actix Web API](https://getrush.ai/run/add-cors/actix/)

## The same job on other stacks

- [Upgrade Axum and Cargo Dependencies](https://getrush.ai/run/upgrade-cargo-dependencies/axum/)
- [Upgrade a Rocket App's Cargo Dependencies Every Week](https://getrush.ai/run/upgrade-cargo-dependencies/rocket/)
- [Upgrade Cargo Dependencies in a Rust CLI](https://getrush.ai/run/upgrade-cargo-dependencies/rust-cli/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
