## TL;DR

The warehouse credentials expired mid-fix and queries started failing with auth errors. The agent should stop, rotate the credentials according to the team's runbook, verify with `dbt debug`, and resume the fix from the failed step.

## Error

```text
warehouse credentials expired mid-fix for the dbt agent: auth error
```

## Steps

1. Confirm it is expiry, not a bad query: auth errors after a period of successful queries indicate lapsed credentials. Expected: the agent classifies correctly.
2. Stop the fix workflow; no query will succeed until credentials are renewed. Expected: no wasted attempts.
3. Rotate the credentials per the team's runbook (refresh the session, assume the role again, or fetch new credentials from the vault). Expected: fresh credentials installed.
4. Verify with `dbt debug`. Expected: the connection check passes before any real work resumes.
5. Resume the fix from the failed step (not from the beginning). Expected: the fix completes on valid credentials.

## When to use

- Warehouse queries flip from working to auth failures mid-run.
- Time-boxed credentials (temporary sessions, short-lived roles).

## When not to use

- Credentials never worked (fix the original configuration).
- The error is a permission denial on a specific object (a grants problem).

## Tool compatibility

- dbt Core 1.0 and later, all warehouses. Rotation mechanics are team-specific.

## Variant phrasings

### Session token expired on Snowflake

Snowflake sessions have lifetimes; re-authenticate and continue.

### SSO session lapsed during a long fix

Browser-based SSO needs a human to re-authenticate; the agent should pause and ask.

## Why it happens

Warehouses issue time-boxed sessions and credentials. A fix session that runs longer than the credential lifetime hits auth failures partway, which masquerade as mysterious mid-run breakage.

## Edge cases

- Some rotations need human approval (SSO, MFA); the agent must pause and request it, not loop.
- Never write raw credential values into logs or files; use the team's secret handling.
- Proactive renewal before long operations prevents the mid-fix failure.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_r2F4bIFfVGJZs8QMMp2UhQ
