Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ jobs:
cache: maven

- name: Initialize CodeQL
uses: github/codeql-action/init@33d7b85da1a04171e211befe2c739303b9a4c066 # v4
uses: github/codeql-action/init@915412ff23e8b7659517e607487dbeae018f2934 # v4
with:
languages: java-kotlin
build-mode: autobuild

- name: Autobuild
uses: github/codeql-action/autobuild@33d7b85da1a04171e211befe2c739303b9a4c066 # v4
uses: github/codeql-action/autobuild@915412ff23e8b7659517e607487dbeae018f2934 # v4
- name: Analyze
uses: github/codeql-action/analyze@33d7b85da1a04171e211befe2c739303b9a4c066 # v4
uses: github/codeql-action/analyze@915412ff23e8b7659517e607487dbeae018f2934 # v4
2 changes: 1 addition & 1 deletion .github/workflows/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Reject new high-severity dependencies
uses: actions/dependency-review-action@a1d282b36b6f3519aa1f3fc636f609c47dddb294 # v5
uses: actions/dependency-review-action@bbc44d14a204704ccc493733616cd1e93a0321ec # v5
with:
fail-on-severity: high
comment-summary-in-pr: always
Expand Down
4 changes: 2 additions & 2 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
wrapperVersion=3.3.4
distributionType=only-script
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.10.1/apache-maven-3.10.1-bin.zip
distributionSha256Sum=9c1ef9174ef250a5009ed0dec97cbe8699acf7479add4e62bf7b0ea791c0adb5
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.10.2/apache-maven-3.10.2-bin.zip
distributionSha256Sum=7d69999d218e025cf1c14691ba748a09706e47999bd505009403cef9d757c2df
31 changes: 31 additions & 0 deletions changelog/v0.2.15.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# v0.2.15

Provider errors stay behind the gateway, the default system prompt grows to 100k, and
usage reporting filters and pages correctly.

## Added

- `/admin/usage` returns `page`, `limit`, `total` and `has_more`; `/admin/audit`
and `/admin/prompt-logs` accept `page`, so long histories are reachable.
- The admin console gains a **Usage** browser (key/end-user/window filters, paging,
CSV export of the filtered set) and an **Audit** log (actor, action, target,
expandable redacted details).

## Changed

- The gateway-wide default system prompt accepts up to 100,000 characters (was
16,000), enough for a full upstream prompt. Migration `V24` widens the column;
the console reads the new limit from `max_chars` and can load a prompt from a file.

## Fixed

- `/admin/usage` now applies `keyId`, `endUser` and `window` in the query. A
key-scoped request used to ignore the window, and an end-user filter ran after
the row limit, so older matching rows disappeared. The CSV export had the same
post-limit filter and could omit a key's rows on a busy gateway.
- Upstream failures no longer leak the provider's own error text. An expired or
revoked provider key returns a gateway-owned `provider_auth_error`, and an
unreachable provider returns `upstream_network_error`, instead of echoing
provider credentials, hostnames or the per-route failure list. A 400/422 still
carries the provider's reason because it describes the caller's own body.
`GATEWAY_EXPOSE_UPSTREAM_DETAIL=true` restores the old passthrough.
11 changes: 6 additions & 5 deletions docs/ADMIN-UI.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ The admin console lives in its own repository, [an1ndra/path-admin](https://gith
## What it covers

Read and write against this API: dashboard (spend, cache, latency, provider circuits, top
models, recent failures), providers (create/edit with a provider API key, probe, delete),
routes (add a model, enable/disable, delete), client keys (create with budgets and
allowlists, top up, revoke), **configuration** (the gateway switches, the default system
prompt, alert email and the daily digest) and **settings** (the session: identity, scopes,
token, sign out).
models, recent failures), usage (filter by key/end user/window, page through rows, export
CSV), audit (every admin write, filterable by action), providers (create/edit with a
provider API key, probe, delete), routes (add a model, enable/disable, delete), client keys
(create with budgets and allowlists, top up, revoke), **configuration** (the gateway
switches, the default system prompt, alert email and the daily digest) and **settings**
(the session: identity, scopes, token, sign out).

## Auth

Expand Down
25 changes: 20 additions & 5 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ Every failure uses the OpenAI envelope:
| `insufficient_credits` | 402 | balance cannot cover the call |
| `rate_limit_exceeded` | 429 | per-key RPM limit (has `Retry-After`) |
| `provider_not_configured` | 502 | provider row has no credential |
| `provider_auth_error` | 502 | upstream rejected the gateway's key |
| `provider_auth_error` | 502 | upstream rejected the gateway's key (expired, revoked or wrong) |
| `upstream_invalid_request` | 400 | upstream rejected the client's body |
| `upstream_timeout` | 504 | connect/read/idle timeout |
| `upstream_network_error` | 502 | the provider could not be reached |
| `upstream_error` | 502 | upstream 5xx or unmapped failure |
| `all_providers_failed` | 502 | every route in the chain failed |
| `circuit_open` | 503 | provider parked by the circuit breaker |
Expand All @@ -58,6 +59,17 @@ Every failure uses the OpenAI envelope:
| `unsupported_endpoint` | 501 | endpoint not available for this provider type |
| `route_exists` / `provider_exists` | 409 | duplicate admin create |

Upstream failures are translated into the gateway's own message. The provider's raw
text is **not** returned by default for authentication, network, timeout and 5xx
failures: it can name the provider, echo part of a credential (some providers include
the key prefix in an auth error), or expose internal hostnames. A 400/422 is the
exception, because its text describes the caller's own body (`context length exceeded`,
`unsupported role`) and is useful; it is passed through unchanged. The full cause is
logged with the provider slug and remains visible through
`POST /admin/providers/{id}/probe`. Set `GATEWAY_EXPOSE_UPSTREAM_DETAIL=true` when
debugging an integration and you want the raw text plus the per-route failure list in
the response.

---

## Public API
Expand Down Expand Up @@ -97,8 +109,9 @@ curl -s -X PUT http://localhost:8080/admin/system-prompt \
-d '{"enabled":true,"text":"Always answer in British English."}'
```

`text` accepts up to 16,000 characters. Enabling with blank text returns 400; disabling
keeps the stored text. The console edits this same endpoint.
`text` accepts up to 100,000 characters. Enabling with blank text returns 400; disabling
keeps the stored text. The console edits this same endpoint and reads the live limit from
`max_chars`.

**Non-streaming**

Expand Down Expand Up @@ -378,9 +391,11 @@ ids land at `0.00` and are flagged in `description`.
|---|---|---|
| GET | `/admin/stats?window=24h` | totals, percentiles, cache, providers/models |
| GET | `/admin/stats?window=24h&bucket=1h` | the same, plus a bucketed time series |
| GET | `/admin/usage?window=24h&limit=100&keyId=` | raw usage rows |
| GET | `/admin/usage?window=24h&limit=100&page=0&keyId=&endUser=` | raw usage rows, paged; the response carries `total` and `has_more` |
| GET | `/admin/audit?limit=100&page=0&action=` | admin writes, newest first |
| GET | `/admin/prompt-logs?limit=50&page=0&keyId=` | stored prompts when logging is on |
| POST | `/admin/digest/test?date=2026-11-19` | send yesterday's summary now and return its text |
| GET | `/admin/usage/export?from=2026-01-01&to=2026-02-01` | CSV for an explicit date slice (archive before a purge) |
| GET | `/admin/usage/export?from=2026-01-01&to=2026-02-01` | CSV for an explicit date slice (archive before a purge); `keyId`, `endUser` and `projectId` filter the query, not the result |

```json
{
Expand Down
1 change: 1 addition & 0 deletions docs/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ except the provider credentials you actually use.
| `GATEWAY_IDEMPOTENCY_MAX_BYTES` | `2097152` | larger responses are not stored for replay |
| `GATEWAY_IDEMPOTENCY_PENDING` | `2m` | abandoned PENDING claims are reclaimed after this |
| `GATEWAY_CACHE_MAX_BYTES` | `2097152` | larger responses are not cached |
| `GATEWAY_EXPOSE_UPSTREAM_DETAIL` | `false` | return the provider's raw error text and per-route details to callers; off keeps the gateway's own wording |

Timeouts live in `application.yml` under `gateway.*`: `connect-timeout` (10s),
`request-timeout` (180s), `stream-idle-timeout` (120s). A provider row can override the
Expand Down
7 changes: 4 additions & 3 deletions docs/OPERATIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,11 @@ curl -s localhost:8080/admin/providers/health -H "$A"

```bash
curl -s 'localhost:8080/admin/stats?window=24h' -H "$A"
curl -s 'localhost:8080/admin/usage?window=7d&limit=50' -H "$A"
curl -s 'localhost:8080/admin/usage?window=7d&limit=50&page=0' -H "$A"
curl -s 'localhost:8080/admin/usage?window=7d&keyId=3&endUser=alice' -H "$A"
curl -s 'localhost:8080/admin/usage/export?window=30d&limit=5000' -H "$A" -o usage.csv
curl -s 'localhost:8080/admin/audit?action=route.update&limit=50' -H "$A"
curl -s 'localhost:8080/admin/prompt-logs?limit=20' -H "$A"
curl -s 'localhost:8080/admin/audit?action=route.update&limit=50&page=0' -H "$A"
curl -s 'localhost:8080/admin/prompt-logs?limit=20&page=0' -H "$A"
```

## CI runners
Expand Down
Loading