Skip to content

fix(deploy): write the GMP secret annotation with a project number - #12081

Merged
Git-on-my-level merged 1 commit into
mainfrom
fix/gmp-secret-annotation-project-number
Aug 23, 2026
Merged

Git-on-my-level merged 1 commit into
mainfrom
fix/gmp-secret-annotation-project-number

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Aug 23, 2026 •

Copy link
Copy Markdown
Member

What still breaks dev

After #12080 got past the container-count check, gcloud itself crashes:

ERROR: gcloud crashed (ValueError): Invalid secret path
'projects/based-hardware-dev/secrets/cloud-run-gmp-config' in annotation

_merge_secret_annotation wrote the config secret into run.googleapis.com/secrets using the project ID. gcloud parses that annotation with a regex whose project segment is numeric (googlecloudsdk/command_lib/run/secrets_mapping.py):

_PROJECT_NUMBER_PARTIAL = r'(?P<project>[0-9]{1,19})'
_REMOTE_SECRET_FLAG_VALUE = r'^projects/' + _PROJECT_NUMBER_PARTIAL + r'/secrets/' + _SECRET_NAME_PARTIAL + _REMOTE_SECRET_VERSION + r'$'

based-hardware-dev is not numeric, so the path is rejected. The fix resolves the project number and writes that.

Why this was expensive to find

Cloud Run accepts the attach with either form. The annotation is only re-parsed by the next gcloud run deploy against that service. So the deploy that introduces the bad annotation succeeds, and a later deploy — touching nothing related — crashes inside a vendored tool. Nothing in the failing run points at #11998.

That is the shape of the new failure class this declares: FC-metadata-format-validated-only-on-next-read. The guard artifact is a test that asserts the annotation against gcloud's actual regex copied verbatim, so a vendor upgrade that tightens the rule fails locally instead of on the next deploy.

Production

Production has no sidecar attached, so it has never written this annotation and does not carry the defect today. On its current code it would have written the bad form on its first deploy and crashed on its second — the same delayed trap as #12080, one layer down.

Note on the live dev service

The dev backend service still carries the bad annotation from the earlier attach. This PR stops it being rewritten, but the existing value needs a one-time repair before dev deploys succeed; that is an operational fix, not a code one.

Verification

patch_service stays pure — attach_sidecar resolves the number and passes it in, so no test needs a subprocess, and a numeric project is passed through without calling gcloud at all.

All 8 tests in tests/unit/test_attach_cloud_run_gmp_sidecar.py pass; the new ones fail against the current script.

Failure-Class: new

Review in cubic

Development backend deploys still fail after #12080, now inside gcloud:

    ERROR: gcloud crashed (ValueError): Invalid secret path
    'projects/based-hardware-dev/secrets/cloud-run-gmp-config' in annotation

`_merge_secret_annotation` wrote the config secret into
`run.googleapis.com/secrets` using the project ID. gcloud parses that
annotation with

    ^projects/(?P<project>[0-9]{1,19})/secrets/(?P<secret>[a-zA-Z0-9-_]{1,255})...

(googlecloudsdk/command_lib/run/secrets_mapping.py), so the project segment
must be numeric. Resolve the project number and write that instead.

The shape of this is worth naming. Cloud Run accepts the attach with either
form, so nothing fails at attach time; the annotation is only re-parsed by
the *next* `gcloud run deploy` on that service. The first deploy after the
sidecar lands succeeds, and the one after it crashes on a service nobody
touched in between -- which is why this read as unrelated to #11998.

Production has no sidecar attached yet, so it has never written this
annotation and is not carrying the defect. It would have written it on its
first deploy and crashed on its second.

`patch_service` stays pure: `attach_sidecar` resolves the number and passes
it in, so no test needs a subprocess. A numeric project is passed through
without calling gcloud at all. The new annotation test asserts against the
gcloud regex verbatim rather than a hand-copied expectation.

Failure-Class: new

Co-Authored-By: Claude Opus 5 <[email protected]>
@Git-on-my-level
Git-on-my-level merged commit c62d985 into main Aug 23, 2026
40 checks passed
@Git-on-my-level
Git-on-my-level deleted the fix/gmp-secret-annotation-project-number branch August 23, 2026 05:48
abunet added a commit to abunet/omi that referenced this pull request Aug 23, 2026
Six commits, no conflicts. Nineteen of the forty files are Swift desktop (legacy Home
visibility, BasedHardware#11933, plus the v0.12.209 changelog). The rest is upstream's Cloud Run / GCP
deploy lane: converging automatic dev deploys (BasedHardware#12019), a preflight that can see past the
metrics sidecar (BasedHardware#12080), and the GMP secret annotation written with a project number
(BasedHardware#12081).

Post-merge audit (ADR-0029/0030): nothing to resolve.

  ports        untouched — no file under database/store/, utils/{auth,vector,object_store}/,
               _client.py, or the notification transport is in the diff at all
  fidelity     the four new backend modules (attach_cloud_run_gmp_sidecar,
               firebase_release_probe_token, preflight-cloud-run-deploy,
               runtime_env_validation/workflows) introduce no raw persistence and no
               firebase_admin.auth — they are deploy tooling, not request-path code
  guards       9/9 exit 0, including the env-parity guard: upstream declared no new runtime
               variable this time

Worth noting for our own backlog: BasedHardware#12080 and the GMP sidecar attach script are the
Cloud Run mechanism behind PROMETHEUS_SIDECAR_PORT, which the previous merge wrote off as a
shape we do not deploy. Upstream building on it confirms the write-off was the right call
rather than a gap on our side.

Verification
  contract lane 55 files, 1083 passed, 78 skipped (live-tier only), 0 failed
  full sweep 1027 files in 3m19s, FAIL set identical to the pre-merge baseline
  upstream's five new backend test files run and pass under our runner
  (8 + 9 + 13 + 18 + 49), and their two new .github guard suites pass (37 + 67 subtests)
Git-on-my-level added a commit that referenced this pull request Aug 23, 2026
Development backend deploys fail at the post-deploy runtime-env validator:

    ERROR [cloud_run/backend]: env MEMORY_ENABLED value mismatch: expected 'on'

The deploy sets it correctly -- the gcloud command carries MEMORY_ENABLED=on
-- and the live revision then holds 'true'. The sidecar attach rewrites it
in between.

gcloud emits YAML 1.2, where `on` is a string; production's untouched export
literally contains `value: on`. PyYAML implements YAML 1.1, where on/off/yes/no
are booleans. `attach_sidecar` safe_loads that export, patches it, and
safe_dumps it back through `services replace`, so `on` lands as the string
'true'. All three of the manifest's on/off keys are rewritten; none survive.

Nothing fails at attach time. Cloud Run stores the rewritten string, and every
consumer accepts the coerced spelling, so behaviour is unchanged. It surfaces
one step later in a validator, on a service nobody edited -- the same delayed
shape as #12080 and #12081.

Restrict the bool resolver to the YAML 1.2 core set so the round trip preserves
what gcloud wrote. safe_dump already quotes ambiguous strings, so only the read
side changes. containerPort, periodSeconds and containerConcurrency still load
as integers and real booleans still load as booleans.

Production has never attached the sidecar, so its export still says `value: on`.
Its first attach would rewrite all three flags and then fail its own gate.

The test fixture is copied verbatim from a real `--format=export` of the
production service, including the unquoted `value: on`. A hand-written fixture
would have been written in the dialect the author already assumes.

Failure-Class: new

Co-authored-by: r <r@r>
Co-authored-by: Claude Opus 5 <[email protected]>
formed2forge pushed a commit to formed2forge/omi that referenced this pull request Aug 24, 2026
…asedHardware#12081)

Development backend deploys still fail after BasedHardware#12080, now inside gcloud:

    ERROR: gcloud crashed (ValueError): Invalid secret path
    'projects/based-hardware-dev/secrets/cloud-run-gmp-config' in annotation

`_merge_secret_annotation` wrote the config secret into
`run.googleapis.com/secrets` using the project ID. gcloud parses that
annotation with

    ^projects/(?P<project>[0-9]{1,19})/secrets/(?P<secret>[a-zA-Z0-9-_]{1,255})...

(googlecloudsdk/command_lib/run/secrets_mapping.py), so the project segment
must be numeric. Resolve the project number and write that instead.

The shape of this is worth naming. Cloud Run accepts the attach with either
form, so nothing fails at attach time; the annotation is only re-parsed by
the *next* `gcloud run deploy` on that service. The first deploy after the
sidecar lands succeeds, and the one after it crashes on a service nobody
touched in between -- which is why this read as unrelated to BasedHardware#11998.

Production has no sidecar attached yet, so it has never written this
annotation and is not carrying the defect. It would have written it on its
first deploy and crashed on its second.

`patch_service` stays pure: `attach_sidecar` resolves the number and passes
it in, so no test needs a subprocess. A numeric project is passed through
without calling gcloud at all. The new annotation test asserts against the
gcloud regex verbatim rather than a hand-copied expectation.

Failure-Class: new

Co-authored-by: r <r@r>
Co-authored-by: Claude Opus 5 <[email protected]>
formed2forge pushed a commit to formed2forge/omi that referenced this pull request Aug 24, 2026
…Hardware#12083)

Development backend deploys fail at the post-deploy runtime-env validator:

    ERROR [cloud_run/backend]: env MEMORY_ENABLED value mismatch: expected 'on'

The deploy sets it correctly -- the gcloud command carries MEMORY_ENABLED=on
-- and the live revision then holds 'true'. The sidecar attach rewrites it
in between.

gcloud emits YAML 1.2, where `on` is a string; production's untouched export
literally contains `value: on`. PyYAML implements YAML 1.1, where on/off/yes/no
are booleans. `attach_sidecar` safe_loads that export, patches it, and
safe_dumps it back through `services replace`, so `on` lands as the string
'true'. All three of the manifest's on/off keys are rewritten; none survive.

Nothing fails at attach time. Cloud Run stores the rewritten string, and every
consumer accepts the coerced spelling, so behaviour is unchanged. It surfaces
one step later in a validator, on a service nobody edited -- the same delayed
shape as BasedHardware#12080 and BasedHardware#12081.

Restrict the bool resolver to the YAML 1.2 core set so the round trip preserves
what gcloud wrote. safe_dump already quotes ambiguous strings, so only the read
side changes. containerPort, periodSeconds and containerConcurrency still load
as integers and real booleans still load as booleans.

Production has never attached the sidecar, so its export still says `value: on`.
Its first attach would rewrite all three flags and then fail its own gate.

The test fixture is copied verbatim from a real `--format=export` of the
production service, including the unquoted `value: on`. A hand-written fixture
would have been written in the dialect the author already assumes.

Failure-Class: new

Co-authored-by: r <r@r>
Co-authored-by: Claude Opus 5 <[email protected]>
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.

1 participant