Repository navigation
fix(deploy): validate rendered runtime env before apply - #12098
Merged
Merged
Conversation
Failure-Class: FC-serialiser-dialect-mismatch-retypes-values
formed2forge
pushed a commit
to formed2forge/omi
that referenced
this pull request
Aug 24, 2026
…e#12098) Failure-Class: FC-serialiser-dialect-mismatch-retypes-values Co-authored-by: r <r@r>
kodjima33
pushed a commit
that referenced
this pull request
Aug 24, 2026
…12114) The pre-deploy runtime-env gate now validates the artifact the renderer produces (#12098), but that artifact only carries services. `_validate_cloud_run` skips its whole job branch when the state has no `jobs` key, so the env, secret and `forbidden_env` contract declared for notifications-job and memory-maintenance-job is no longer checked anywhere: the job workflows run the validator with `--check-workflows` only, and the post-deploy live check is services-only by design. The comment in `_fetch_live_cloud_run_state` still promises that "the job contract is still validated statically against the rendered state". Render jobs into the state from the same helpers that already render their deploy inputs in the same invocation, so the gate sees them again. Failure-Class: FC-mirrored-model-omits-new-member
This was referenced Aug 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
render_backend_runtime_env.pyemit validator state from the same literal env values, secret references, and network flags it sends todeploy-cloudrun(backend/scripts/render_backend_runtime_env.py:96-100,backend/scripts/render_backend_runtime_env.py:190-207)..github/actions/deploy-backend-stack/action.yml:416-439).services replace(backend/scripts/attach_cloud_run_gmp_sidecar.py:392-417,backend/scripts/attach_cloud_run_gmp_sidecar.py:451-482).--check-rendered-cloud-runvalidator mode; offline pre-deploy validation now uses the same--cloud-run-stateinput contract as every other offline state check (backend/scripts/runtime_env_validation/manifest.py:636-680).Root cause
PR #11998 introduced the exact coercion boundary in
backend/scripts/attach_cloud_run_gmp_sidecar.py: its original version parsedgcloud run services describe --format=exportwithyaml.safe_loadat line 287 and wrote the result back withyaml.safe_dumpat line 325. gcloud emits YAML 1.2, where plainon/offare strings; PyYAML's safe loader uses YAML 1.1 boolean resolution. The load therefore changedoff/off/onintoFalse/False/True, and the dump plusgcloud run services replacepersistedfalse/false/true.The loader correction from PR #12083 is already on this branch's current
main:GcloudExportLoaderrestricts boolean resolution to the YAML 1.2 core spellings (backend/scripts/attach_cloud_run_gmp_sidecar.py:21-48) and the export is read with it (backend/scripts/attach_cloud_run_gmp_sidecar.py:409). This PR makes that correction fail closed against the deploy's rendered contract, so a future dialect regression cannot reachservices replace(backend/scripts/attach_cloud_run_gmp_sidecar.py:253-268,backend/tests/unit/test_attach_cloud_run_gmp_sidecar.py:309-391).The pre/post disagreement was separate: before this PR,
_build_rendered_cloud_run_stateinbackend/scripts/runtime_env_validation/cloud_run.py:32-106copied values directly out of the manifest, so--check-rendered-cloud-runcompared the manifest to itself. The post-deploy path read actual Cloud Run state. The pre-deploy pass therefore said nothing about the renderer or sidecar round trip. The workflow now validates the actual renderer artifact and gives that same artifact to the only export/replace mutation (.github/actions/deploy-backend-stack/action.yml:416-439,.github/actions/deploy-backend-stack/action.yml:483-503).Guard placement
This is not a new shared primitive: the GMP attach is the only backend deploy step that exports a whole Cloud Run service, edits it, and replaces it. The local pre-apply guard is therefore at that mutation boundary and directly covers the failure introduced by PR #11998 and observed in run 32620507075 (
backend/scripts/attach_cloud_run_gmp_sidecar.py:392-482). The general renderer/validator contract remains shared through the JSON state consumed byvalidate_runtime_env(backend/scripts/render_backend_runtime_env.py:190-207,backend/scripts/runtime_env_validation/manifest.py:672-680).I did not add a lexical ban on unquoted
on/off/yes/noin the checked-in runtime manifest. All 373 currentvaluenodes load as strings, and the incident manifest values were already quoted; such a ban would guard the wrong producer and would reject valid YAML 1.2 output from gcloud. The behavioral tests instead cover all four tokens at the renderer boundary and force a YAML 1.1 retype at the export/replace boundary (backend/tests/unit/test_render_backend_runtime_env.py:75-113,backend/tests/unit/test_attach_cloud_run_gmp_sidecar.py:331-390).Verification
Red-first confirmation before the implementation:
test_render_backend_runtime_env.pyfailed because no rendered-state function/artifact existed.test_attach_cloud_run_gmp_sidecar.pyshowed the simulated YAML 1.1 retype reachedservices replacewithout raising.test_verify_backend_release_vector.pyshowed the pre-deploy validator still ran before the real render.Focused green tests, run as individual modules:
test_render_backend_runtime_env.py: 25 passed.test_attach_cloud_run_gmp_sidecar.py: 11 passed.test_backend_runtime_env_validator.py: 85 passed.test_verify_backend_release_vector.py: 49 passed.test_workflow_contracts.py: 25 passed.test_listen_finalization_cloud_tasks.py: 97 passed.Additional checks:
validate-backend-runtime-env.py --env prod --check-workflows --cloud-run-state <state>passed and the state contained exactoff/off/onvalues.bash backend/scripts/check_runtime_env_compose.shreportedbackend/deploy/runtime_env.yaml is up to date.gcloud run revisions describereconfirmed the serving revision hasoff/off/onand the rejected candidate hasfalse/false/truefor the three affected flags.Product invariants
None (
scripts/pr-preflight --suggest).Failure-Class: FC-serialiser-dialect-mismatch-retypes-values