Skip to content

fix(gateway): treat archived key metadata as absent - #362

Merged
FumingZhang merged 1 commit into
mainfrom
fix/gateway-archived-key-readback
Oct 30, 2026
Merged

FumingZhang merged 1 commit into
mainfrom
fix/gateway-archived-key-readback

Conversation

@FumingZhang

Copy link
Copy Markdown
Member

Summary

Treat LiteLLM key metadata with a non-null deleted_at as an absent key.
The management API can return HTTP 200 for a deletion archive even when the
live key list is empty and requests using that key are rejected. Reading that
archive as a current key could incorrectly reuse its old model/budget evidence.

Decode the optional deletion timestamp with its actual type, retain the existing
active/404 behavior, and surface malformed deletion metadata as an error. Add
focused HTTP-client tests and document the distinction between archives and
the separate per-replica authentication cache window.

Related issue

Discovered during the authorized AKS validation associated with #354. This is
an independent Gateway API compatibility repair against main; no separate
issue is needed for the already requested validation-and-repair work.

Validation

Offline checks used Go 1.27.3, the pinned local toolchain, an empty kubeconfig,
and USE_EXISTING_CLUSTER=false.

Command: go -C app/cetirun-operator test ./internal/aigateway -run '^TestGetKeyDistinguishesDeletionArchives$' -count=1
Result: reproduced the archived-key and two malformed-metadata failures before the fix (0.007s).

Command: go -C app/cetirun-operator test ./internal/aigateway ./internal/controller -run 'Test(GetKey|.*AIGateway)' -count=1 -timeout=10m
Result: passed; client 0.011s and controller 1.094s.

Command: go -C app/cetirun-operator test -race ./internal/aigateway -count=1
Result: passed, 1.067s; full Gateway client package.

Command: go -C app/cetirun-operator vet ./internal/aigateway ./internal/controller
Result: passed.

Command: go -C app/cetirun-operator build ./...
Result: passed.

Command: make docs-check
Result: passed, including 43 generated HTML pages and source headers.

Command: git diff --check
Result: passed.

Not run at PR creation: the entire Operator suite or deployment of the new binary.

Authorized live protocol observation: exact synthetic Agent aliases had zero
live keys and one archived key with a deletion timestamp after ordinary Agent
deletion. The old key-use probes returned HTTP 401 while /key/info still
returned HTTP 200. No live credentials, identifiers, responses or diagnostic
bundle are attached.

Compatibility and operational impact

No CRD, configuration, dependency, grant, retention, or timeout change. Older
responses that omit deleted_at and active responses with deleted_at: null
keep their existing behavior. Archived records remain available for accounting;
the client does not delete or mutate them. This does not claim to eliminate
the Gateway's documented replica cache propagation window.

Checklist

  • The change is focused and preserves unrelated work.
  • Tests cover the changed behavior, or I explained why no new test is needed.
  • Documentation and examples match any public behavior changes.
  • Generated artifacts were updated from source, or none are affected.
  • Dependency changes include lockfiles, source attribution, and license information, or none are affected.
  • I checked the diff and attachments for secrets, private endpoints or identifiers, customer data, agent conversations, and internal information.
  • I followed the applicable CLA instructions, or asked a maintainer about an unclear check.
  • I identified checks that need credentials or a live environment and did not run them without authorization.

Recognize LiteLLM deletion archives returned with HTTP 200 without treating their old model or budget fields as current key evidence. Preserve active and not-found handling, fail explicitly on malformed deletion metadata, and keep archive retention and cache policy unchanged.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

@feiskyer Pengfei Ni (feiskyer) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@FumingZhang
FumingZhang merged commit 5571636 into main Oct 30, 2026
34 checks passed
@FumingZhang
FumingZhang deleted the fix/gateway-archived-key-readback branch October 30, 2026 02:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants