Repository navigation
Commit 49ffccd
* feat(vertex): accept pasted GCP credential JSON in the API-key slot (#6821)
Let the provider's API-key field take a Service Account JSON directly:
- gcp-adc: a `gcp-sa:<account>` marker resolves the credential from the OS
keychain (same service + entry factory as `keychain:` references) and runs
the existing service_account JWT / authorized_user flow. The marker sits
above GOOGLE_APPLICATION_CREDENTIALS in the source priority; everything
downstream (token cache, refresh skew, in-flight dedup) is untouched.
- api-keys: addProviderApiKey detects a pasted credential JSON (single,
pretty-printed, or comma-separated for future pool rotation), verifies the
"type" field, stores the secret in the OS keychain with a read-back check,
and persists only the marker to config. File paths are rejected with
paste guidance; unrecognized types are rejected before anything is stored.
- router: usableResolvedApiKey registers the active `gcp-sa:` marker with
the ADC resolver, so a marker in any pool entry becomes the active source.
- adapters/google: vertex's API-key fast path skips `gcp-sa:` markers —
they are not API-key material and must reach the ADC branch instead.
Markers keep resolveProviderApiKey synchronous (no signature changes) and
work naturally with the existing 429 key-pool failover: each pool entry can
independently hold a raw key, an ${ENV} ref, a keychain: ref, or a gcp-sa:
marker, and per-key cooldown rotation applies unchanged.
Closes #6821 (partially — live model discovery for vertex mode is a
separate discussion).
Co-Authored-By: Claude <noreply@anthropic.com>
* refactor(vertex): pass the marker account per request; review fixes (#6842)
Address CodeRabbit findings:
- gcp-adc: remove the process-global activeMarkerAccount/registration
(a module-level marker would race across concurrent requests for
different providers and could resolve one call with another provider's
credential). The marker account now travels per request via
getVertexAccessToken(options.markerAccount) and flows through
currentAdcSourceKey/loadAdcCredentials as an argument. The reconcile
sweep passes no marker (no request context) — marker entries are
pruned by expiry instead.
- adapters/google: pass gcpCredentialMarkerAccount(provider.apiKey)
per request. router: drop the registration; the routed provider
config carries the marker verbatim.
- api-keys: delete a just-written keychain entry ONLY when the write
created it — on a failed commit, an upsert must keep the credential
the previous reference still names.
- tests: narrow the adapter assertion to the ADC-shaped request (URL +
Bearer header + no x-goog-api-key, with a stubbed fetch), and
isolate the marker-source tests from host ADC state (empty
CLOUDSDK_CONFIG, no GOOGLE_APPLICATION_CREDENTIALS, 404 fetch stub).
Co-Authored-By: Claude <noreply@anthropic.com>
* fix(vertex): preserve the marker through routing; harden paste handling (#6842)
Address CodeRabbit round-2 findings:
- router: usableResolvedApiKey returns gcp-sa: marker values UNCHANGED —
replacing a marker with undefined (it resolves to no key material) would
silently drop it from the routed config and send the vertex adapter to
host ADC instead of the configured service account.
- api-keys: storeGcpCredentialJson takes existedBefore and deletes the
keychain entry after a read-back mismatch only when the entry did not
exist before the write — a re-paste targets an account an existing
marker already names, and deleting it would destroy the live credential.
- api-keys: splitCredentialPaste honors the parseGcpCredentialJson contract
(a single-line brace-leading literal is never eaten — it falls back to a
plain key row), tracks JSON string/escape state in the brace scanner (a
} inside a string field no longer splits early), and rejects
non-separator content before/between objects instead of discarding it.
- tests: router-level pass-through test (routedProviderConfig preserves
the marker), end-to-end test (routed config feeds buildRequest, ADC
branch wins), literal-key fallback + gap-rejection tests. Markers keep
resolveProviderApiKey synchronous.
Co-Authored-By: Claude <noreply@anthropic.com>
* docs: attest review readiness checklist (4/4 ticked)
* docs: attest readiness 4/4; trigger gate re-evaluation
* fix(gcp-adc): suppress the GOOGLE_CLOUD_API_KEY fallback for named markers; strict paste validation (#6842)
Address Prana review findings:
- adapters/google: a `gcp-sa:` marker means the operator named ONE credential
explicitly — the GOOGLE_CLOUD_API_KEY env fallback no longer fires. Without
this guard, a marker + env key would silently route the provider's inference
through the ambient env key instead of the configured service account.
- providers/api-keys (capture): a parseable JSON object with an unrecognized
"type" field (e.g. external_account) is REJECTED with guidance, not saved as
a plaintext literal key — saving it would send it to the wire verbatim.
Non-JSON brace values ({abc:def}) keep their key-compat behavior.
- providers/api-keys (tail): content after the LAST object's close up to EOF
is validated like the mid-gaps — trailing garbage is rejected, not silently
kept. (Covers captureTrailing otherwise.)
Registrations: per-finding regression tests added (explicit-credential-wins
for markers, JSON-with-unknown-type rejection, tail-gap rejection).
Co-Authored-By: Claude <noreply@anthropic.com>
* test(vertex): cover trailing credential paste validation
* fix(gcp-adc): validate markers and clean up credential lifecycle
* fix(gcp-adc): clean credentials after provider batch and overwrite commits
* fix(management): include durable provider markers in DELETE cleanup
Co-Authored-By: Claude <noreply@anthropic.com>
* fix(gcp-adc): validate required fields in parseGcpCredentialJson before persistence
Co-Authored-By: Claude <noreply@anthropic.com>
* style(management): keep GCP cleanup within file-size gate
* fix(vertex): reject credential JSON before generic provider persistence
* fix(vertex): preserve GCP keychain payloads across key migrations
* fix(vertex): serialize credential writes with marker commits and cleanup
* fix(cli): clean removed GCP credentials after provider overwrite
* fix(cli): collect durable GCP markers under overwrite lock
* fix(cli): validate raw keys before registry auth ignores them
* fix(gcp-adc): isolate blank markers during credential cleanup
* fix(vertex): close credential input, alias and removal lifecycle gaps
Reject wrapped or malformed credential material before literal persistence or restore, and prevent keychain aliases exposing GCP JSON as wire keys. Revalidate marker readability before cached-token use. Capture deletion candidates and persist CLI/management removal under one mutation lock, preserving post-commit shared-reference cleanup. Cover mixed SA/key failover and DTO redaction with synthetic credentials.
Co-authored-by: GSL-R <174104911+GSL-R@users.noreply.github.com>
* fix(vertex): classify JSON-escaped credentials before alias resolution
Decode structured JSON before credential classification so escaped field and type names cannot enter literal key resolution or keychain restore.
Co-authored-by: GSL-R <174104911+GSL-R@users.noreply.github.com>
* fix(vertex): refuse structured JSON carriers as literal keys
Reject object, array and quoted-string carriers directly so nested or escaped GCP credential material cannot bypass alias, ingestion or restore validation. Preserve non-JSON literal token handling and dedicated supported GCP-object ingestion.
Co-authored-by: GSL-R <174104911+GSL-R@users.noreply.github.com>
* refactor(management): extract GCP credential route handling
Move credential-input rejection responses and locked provider deletion into a cohesive sibling module. Preserve validation responses, mutation ordering, save callback and post-commit cleanup behavior while keeping provider-routes.ts below the fixed 2000-line limit after dev integration.
Co-authored-by: GSL-R <174104911+GSL-R@users.noreply.github.com>
---------
Co-authored-by: GSL-R <gslee0922@gmail.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: GSL-R <174104911+GSL-R@users.noreply.github.com>
1 parent 17e307d commit 49ffccd
23 files changed
Lines changed: 1887 additions & 44 deletions
File tree
- docs-site/src/content/docs/reference/configuration
- scripts/test-layout
- src
- adapters
- cli
- lib
- providers
- server/management
- structure
- providers
- tests
- adapters/google
- fixtures
- server
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1502 | 1502 | | |
1503 | 1503 | | |
1504 | 1504 | | |
| 1505 | + | |
| 1506 | + | |
| 1507 | + | |
| 1508 | + | |
| 1509 | + | |
| 1510 | + | |
| 1511 | + | |
| 1512 | + | |
| 1513 | + | |
| 1514 | + | |
| 1515 | + | |
| 1516 | + | |
| 1517 | + | |
| 1518 | + | |
| 1519 | + | |
| 1520 | + | |
| 1521 | + | |
| 1522 | + | |
| 1523 | + | |
| 1524 | + | |
| 1525 | + | |
| 1526 | + | |
| 1527 | + | |
| 1528 | + | |
| 1529 | + | |
| 1530 | + | |
1505 | 1531 | | |
1506 | 1532 | | |
1507 | 1533 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
174 | 174 | | |
175 | 175 | | |
176 | 176 | | |
177 | | - | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
178 | 186 | | |
179 | 187 | | |
180 | 188 | | |
| |||
1197 | 1205 | | |
1198 | 1206 | | |
1199 | 1207 | | |
1200 | | - | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
1201 | 1213 | | |
1202 | 1214 | | |
1203 | 1215 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
18 | 20 | | |
19 | 21 | | |
20 | 22 | | |
| |||
223 | 225 | | |
224 | 226 | | |
225 | 227 | | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
226 | 234 | | |
227 | 235 | | |
228 | 236 | | |
| |||
249 | 257 | | |
250 | 258 | | |
251 | 259 | | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
252 | 266 | | |
253 | 267 | | |
254 | 268 | | |
| |||
328 | 342 | | |
329 | 343 | | |
330 | 344 | | |
| 345 | + | |
331 | 346 | | |
332 | 347 | | |
333 | 348 | | |
334 | 349 | | |
335 | 350 | | |
336 | 351 | | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
337 | 356 | | |
338 | 357 | | |
339 | 358 | | |
| |||
344 | 363 | | |
345 | 364 | | |
346 | 365 | | |
| 366 | + | |
347 | 367 | | |
348 | 368 | | |
349 | 369 | | |
| |||
440 | 460 | | |
441 | 461 | | |
442 | 462 | | |
443 | | - | |
444 | | - | |
445 | | - | |
446 | | - | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
447 | 469 | | |
448 | 470 | | |
449 | 471 | | |
| |||
0 commit comments