Repository navigation
[codex] Fix backend runtime config validation - #8651
Conversation
There was a problem hiding this comment.
1 issue found across 11 files
Confidence score: 3/5
- In
backend/utils/google_credentials.py, the current write-then-chmodflow can briefly leaveSERVICE_ACCOUNT_JSONreadable with broader permissions (especially in/tmpor if the target already exists with permissive mode), creating a real secret-exposure risk if merged as-is — create/open the file with0600from the start before writing the JSON.
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3d5ca460be
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
3d5ca46 to
2c6a184
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2c6a184967
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
2c6a184 to
7fcbd35
Compare
|
Addressed the credential runtime feedback. What changed:
Verification passed:
|
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7fcbd35f13
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| - name: Capture ${{ env.SERVICE }} revision | ||
| id: capture-backend-revision | ||
| run: | | ||
| revision="$(gcloud run services describe backend --region=${{ env.REGION }} --format='value(status.latestCreatedRevisionName)')" |
There was a problem hiding this comment.
Capture this deploy's revision deterministically
In this no-traffic flow, the capture step reads the service-wide status.latestCreatedRevisionName; if two auto-dev pushes overlap (this workflow has no concurrency guard), an earlier run can capture a revision created by the later run and then shift traffic to that image while its GKE listen deployment still uses the earlier SHA. Use a deterministic revision suffix/tag for this deploy or serialize runs before relying on the captured revision.
Useful? React with 👍 / 👎.
| from google.cloud import firestore | ||
|
|
||
| from database.document_ids import document_id_from_seed | ||
| from utils.google_credentials import prepare_google_credentials |
There was a problem hiding this comment.
Keep database from importing the utils layer
backend/AGENTS.md requires the import hierarchy database/ -> utils/ -> routers/ -> main.py, with higher layers importing lower ones; this new database → utils edge violates that contract and can turn the many existing utils imports of database into startup circular-import failures. Move the credential helper into a lower-level module or keep preparation outside database/_client.py.
Useful? React with 👍 / 👎.
| from utils import google_credentials | ||
|
|
||
|
|
||
| def test_service_account_json_materializes_credentials_file(monkeypatch, tmp_path): |
There was a problem hiding this comment.
Add the new credential tests to the backend runner
backend/AGENTS.md says new backend test files must be added to backend/test.sh; this new pytest module is not listed there, so the CI source-of-truth runner will skip these credential-materialization tests. Add a pytest tests/unit/test_google_credentials.py -v entry alongside the other unit tests.
Useful? React with 👍 / 👎.
Summary
SERVICE_ACCOUNT_JSONand block accidentalgoogle-credentials.jsonimage bakingRoot Cause
Cloud Run and GKE backend runtime config drifted because env vars, secrets, credentials, and private networking were defined across separate deploy surfaces. Cloud Run revisions could be created before all expected runtime config was present, including the credential binding needed to materialize
google-credentials.json.Review
Validation
python3 backend/scripts/validate-backend-runtime-env.py --env dev --check-workflowspython3 backend/scripts/validate-backend-runtime-env.py --env prod --check-workflowspython3 -m pytest backend/tests/unit/test_backend_runtime_env_validator.py backend/tests/unit/test_google_credentials.py -qpython3 -m py_compile backend/utils/google_credentials.py backend/scripts/validate-backend-runtime-env.py backend/main.py backend/database/_client.pygit diff --checkbash backend/test-preflight.sh(passed; warns that optional local packages/services like Firestore/Redis are not installed)Fixes #8515