Skip to content

fix(backend): remove stale SERVICE_ACCOUNT_JSON mapping from ExternalSecrets and rollouts - #10173

Closed
aryanorastar wants to merge 5 commits into
BasedHardware:mainfrom
aryanorastar:fix/9187-external-secret-stale-key
Closed

aryanorastar wants to merge 5 commits into
BasedHardware:mainfrom
aryanorastar:fix/9187-external-secret-stale-key

Conversation

@aryanorastar

@aryanorastar aryanorastar commented Jul 21, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #9187

Summary

Removes the stale SERVICE_ACCOUNT_JSON key mapping from both prod and dev backend-secrets Helm charts and the runtime_env.yaml Cloud Run deployment manifests.

This resolves the prod-omi-backend-external-secret reporting SecretSyncedError because it tried to reference the deleted Secret Manager key. Auth now relies purely on GOOGLE_APPLICATION_CREDENTIALS.

Failure-Class: none

Review in cubic

aryanorastar and others added 4 commits July 20, 2026 02:03
The provider-timeout class (FC-per-hop-timeout: BasedHardware#8640, BasedHardware#8911, BasedHardware#9135,
BasedHardware#9644) was fixed four times by moving a per-hop timeout. The Anthropic
chat path now owns one admission budget instead:

- RequestDeadline (240s inside the 300s platform bound, mirroring the
  Gemini proxy) is created in route middleware before extractors and
  body extraction; auth, BYOK, and paywall waits are bounded by it and
  budget exhaustion returns a typed 504 instead of a 401.
- All provider sends go through send_with_deadline; the retry loop is a
  budget-aware policy: attempts never start on an expired budget, a
  retry or pause_turn continuation starts only above a 10s floor, and
  backoff sleeps truncate at the budget edge. A transient status on the
  final available attempt still passes through unchanged.
- The budget governs everything before the first client-visible semantic
  SSE event. The stream idle timer now measures SEMANTIC progress:
  raw bytes and Anthropic ping events no longer reset it, closing the
  live gap where a ping-only upstream could hold a client forever with
  nothing visible. Streaming still has no total response timeout by
  design (BasedHardware#9135): a visible-delta stream survives budget expiry.
- The detached Firestore usage write runs through a spawn seam that
  never inherits the request deadline.

Behavioral tests drive the policy and the real stream translator with
tokio::time::pause: budget-floor retry stop, backoff truncation at the
edge, long visible streams surviving expiry, ping-only turns ending in a
typed terminal SSE error, semantic-idle stalls independent of budget,
and detached-write completion after expiry.

Fixes BasedHardware#9835.

Co-Authored-By: Claude Fable 5 <[email protected]>
Static tripwire (labeled as such): raw reqwest builders are not covered
by signatures alone, so new direct .send() calls in routes/chat/ fail
the manifest lanes. Behavioral coverage lives in the paused-time
deadline tests. Caught class: BasedHardware#8640/BasedHardware#8911/BasedHardware#9135/BasedHardware#9644 (BasedHardware#9835).

Co-Authored-By: Claude Fable 5 <[email protected]>
…eadline

Named follow-up from BasedHardware#9835: proxy.rs kept a working ad hoc deadline; the
budget type now exists, so the migration is mechanical.

- The shared race/within helpers and DeadlineElapsed move to
  request_deadline.rs; the proxy-local copies are deleted (no aliases,
  all call sites and tests migrate in this change).
- The budget is admitted by the shared route middleware before extractors
  on both proxy routes, so auth/BYOK/paywall waits are inside it. The
  handler consumes the same RequestDeadline the chat path uses; the
  phase-aware timeout telemetry mapping is unchanged.
- CHAT_REQUEST_BUDGET generalizes to REQUEST_BUDGET (same 240s value both
  route classes already derived from the platform contract); the proxy's
  platform constants collapse into the shared module. Per-attempt Gemini
  defenses (connect bound, attempt cap) stay proxy-owned policy.
- The streaming proxy keeps no total response timeout by design; it gains
  only budgeted extractor waits.
- New behavioral test: the middleware-admitted budget is the one the
  handler consumes, on the paused tokio clock.

Existing proxy deadline tests (hanging-upstream cancellation, downstream
disconnect propagation, one-budget-includes-pre-dispatch-work) migrate to
the shared helpers with assertions unchanged.

Refs BasedHardware#9835.

Co-Authored-By: Claude Fable 5 <[email protected]>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@aryanorastar

Copy link
Copy Markdown
Collaborator Author

⚠️ Correction — this is not a stale mapping. Do not merge without confirming prod Workload Identity.

While splitting this PR I checked whether SERVICE_ACCOUNT_JSON is actually unused. It is read by four production modules, each as the preferred Google credential source with an ADC fallback:

  • backend/main.py — Firebase Admin init (else: firebase_admin.initialize_app())
  • backend/pusher/main.py — Firebase Admin init (same ADC fallback)
  • backend/database/google_credentials.py — Google creds (falls back to GOOGLE_APPLICATION_CREDENTIALS)
  • backend/utils/other/storage.py — GCS client (else: storage.Client() via GCE metadata)

backend/AGENTS.md documents it as "Firestore/GCS credentials."

So removing the binding reroutes prod Firebase Admin + GCS auth through ADC. That is safe only if the prod GKE cluster runs Workload Identity so initialize_app() and storage.Client() authenticate without the secret. If WI is not configured, this breaks Firebase + GCS at deploy.

Separately, this branch also stacks the change on top of the entire #10054/#10056 chat-deadline work (20 files) rather than the 2-file ExternalSecrets change alone.

Recommend: hold until prod Workload Identity is confirmed, then reland as a focused, accurately-framed WI-migration PR (not "remove stale mapping").

@Git-on-my-level Git-on-my-level added needs-maintainer-review Needs a human maintainer to sign off before merge security-review Touches auth, provider routing, secrets, or security-sensitive surfaces needs-scope-reduction PR scope should be reduced or split labels Jul 21, 2026

@Git-on-my-level Git-on-my-level 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.

Thanks for chasing the ExternalSecret sync issue here.

I’m going to request changes because the current branch is not safe to merge in this shape:

  • The SERVICE_ACCOUNT_JSON binding does not appear to be stale in code: it is still read by backend Firebase/GCS credential paths (backend/main.py, backend/pusher/main.py, backend/database/google_credentials.py, backend/utils/other/storage.py) and documented in backend/AGENTS.md. Removing it reroutes production auth to ADC / Workload Identity, which needs explicit maintainer confirmation for prod before merge.
  • The PR is stacked with a separate desktop Rust chat-deadline/CI tripwire change. That may be useful work, but it is unrelated to the ExternalSecrets fix and materially changes another subsystem plus CI behavior, making this hard to validate or roll back as a focused secrets/deploy fix.
  • Required checks are currently failing, including Static Contracts, Rust Backend, Backend unit suite, Desktop Swift Build & Tests, and Desktop Swift Test Suites.

Suggested path: split/reland the ExternalSecrets change as a focused PR only after prod Workload Identity / ADC coverage is confirmed, and keep the chat-deadline work in its own PR with its failing checks resolved.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@aryanorastar

aryanorastar commented Jul 21, 2026 •

Copy link
Copy Markdown
Collaborator Author

Update — the removal is not just risky, it's blocked and wrong. The pre-push runtime-env validator (scripts/validate-backend-runtime-env.py) rejects it:

ERROR [dev/cloud_run/jobs/memory-maintenance-job]: missing secret SERVICE_ACCOUNT_JSON

memory-maintenance-job (and other services) declare SERVICE_ACCOUNT_JSON as a required env secret in backend/deploy/runtime_env.yaml — so deleting its definition breaks the runtime-env contract, on top of the four code readers (main.py, pusher/main.py, google_credentials.py, storage.py) that use it as their preferred credential.

That settles the "stale" question: it isn't. #9187's actual symptom is that the ExternalSecret references a Secret Manager key that was deleted upstream → SecretSyncedError. The fix is therefore an ops action — restore the SERVICE_ACCOUNT_JSON key in Secret Manager — or a full, coordinated Workload-Identity migration (move every reader and memory-maintenance-job to ADC, confirm prod WI, then remove). Neither is a YAML-deletion PR.

closing this PR and handling #9187 as an ops/infra restore. I scope-reduced the branch to just the ExternalSecrets change to check, and it fails the validator by construction — there's no mergeable version of "remove the binding."

@github-actions

Copy link
Copy Markdown
Contributor

Hey @aryanorastar 👋

Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request.

After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:

  • Project standards — Ensuring consistency across the codebase
  • User needs — Making sure changes align with what our users need
  • Code best practices — Maintaining code quality and maintainability
  • Project direction — Keeping aligned with our product principles and locked invariants

Before your next PR, please skim:

  • PRODUCT.md — product north star
  • Product invariants — locked rules (shared chat, memory tiers, agent control plane, integrations, brand)

If this was declined for direction or taste, maintainers should cite an invariant ID or open a proposed one — ask if that citation is missing.

Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out.

Thank you for being part of the Omi community!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-maintainer-review Needs a human maintainer to sign off before merge needs-scope-reduction PR scope should be reduced or split security-review Touches auth, provider routing, secrets, or security-sensitive surfaces

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prod GKE backend ExternalSecret still references missing SERVICE_ACCOUNT_JSON

2 participants