Skip to content

fix(skills): empty-string env vars fall back to "unknown" in /skills/bundled envelope - #48

Merged
cryptolir merged 1 commit into
mainfrom
fix/skills-bundled-empty-env-fallback
May 24, 2026
Merged

cryptolir merged 1 commit into
mainfrom
fix/skills-bundled-empty-env-fallback

Conversation

@cryptolir

Copy link
Copy Markdown
Owner

Small follow-up to PR #47 — addresses the OPENCLAW_IMAGE_SHA nuance Codex flagged in re-review and a related empty-string fallback bug.

The bug

PR #47 added OPENCLAW_IMAGE_TAG / OPENCLAW_IMAGE_SHA / OPENCLAW_SOURCE_SHA to the runtime envelope using process.env.X ?? "unknown". The Dockerfile declares these as ARG ... = "", so when a --build-arg is unset, the resulting runtime env var is an empty string, not undefined. ?? only triggers on null/undefined, so the envelope would have returned "imageTag": "" instead of "unknown" — confusing rather than useful.

The fix

  • Added buildEnvOr(name, fallback) helper that treats undefined, null, and "" as missing.
  • Replaced all three reads in buildEnvelope with the helper.
  • Added test (a2) asserting empty-string env produces "unknown".

imageSha nuance (documented inline)

Per Codex's re-review: the Artifact Registry digest is not known inside a single-pass docker build — it's produced by docker push afterward. So OPENCLAW_IMAGE_SHA cannot be baked in via --build-arg. The route's buildEnvelope now has a comment explaining this; the field will stay "unknown" until Phase 3's release-record join (canonical-skill-registry plan §8) populates it from the post-push output.

The DevAgents build script (/opt/openclaw-ops/scripts/build-and-push.sh) was patched today to pass the two args that CAN be baked in (OPENCLAW_IMAGE_TAG, OPENCLAW_SOURCE_SHA) — recorded in STATUS.md.

Validation

pnpm test src/gateway/routes/skills-bundled.test.ts  → 14/14 pass (was 13)
pnpm exec oxfmt --check <changed files>              → clean

Test plan

  • Codex re-confirms the buildEnvOr semantics + Phase-3 promise for imageSha
  • Maintainer comfortable merging given pre-existing CI noise (labeler / install-smoke / non-PR format errors)

🤖 Generated with Claude Code

PR #47 introduced `OPENCLAW_IMAGE_TAG` / `OPENCLAW_IMAGE_SHA` /
`OPENCLAW_SOURCE_SHA` build args, but used `?? "unknown"` for the
runtime read. The Dockerfile declares these as `ARG ... = ""`, so an
unset --build-arg comes through at runtime as an empty string (not
undefined) — and `??` only triggers on null/undefined, leaving the
gateway envelope with `"imageTag": ""` etc.

Adds a `buildEnvOr(name, fallback)` helper that treats undefined,
null, and "" as missing, and uses it for all three fields. Also adds
test (a2) asserting empty-string env vars produce "unknown" in the
envelope.

Also documents (inline comment + STATUS.md note) why `imageSha`
specifically will remain "unknown" until Phase 3 of the canonical
skill registry plan — the Artifact Registry digest isn't known
inside a single-pass `docker build`, so we can't bake it in via
--build-arg. Release-record join (plan §8) will populate it post-push.

STATUS.md records the corresponding ops change applied on DevAgents
to /opt/openclaw-ops/scripts/build-and-push.sh — it now passes the
new build args (TAG + SOURCE_SHA), with backup file alongside.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@cryptolir

Copy link
Copy Markdown
Owner Author

Codex review of PR #48 (cd9017509): no code findings.

Confirmed:

  • buildEnvOr correctly treats undefined, null, and empty string as missing and returns "unknown".
  • The new regression test covers Dockerfile-style empty-string env values for OPENCLAW_IMAGE_TAG, OPENCLAW_IMAGE_SHA, and OPENCLAW_SOURCE_SHA.
  • The inline imageSha comment matches the PR feat(skills): canonical skill registry manifest + bundled endpoints #47 review nuance: the final Artifact Registry digest is produced after push, so it cannot be baked into a single-pass docker build; keeping imageSha: "unknown" until the Phase 3 release-record join is the right contract.
  • Verified DevAgents ops state: /opt/openclaw-ops/scripts/build-and-push.sh now passes --build-arg OPENCLAW_IMAGE_TAG="${TAG}" and --build-arg OPENCLAW_SOURCE_SHA="${SOURCE_SHA}", and intentionally does not pass OPENCLAW_IMAGE_SHA.

Validation run on DevAgents in a disposable clone at cd901750987f63aac889f413a6bdb1a2477ba855:

  • pnpm install --frozen-lockfile passed
  • pnpm test src/gateway/routes/skills-bundled.test.ts passed, 14/14
  • pnpm exec oxfmt --check src/gateway/routes/skills-bundled.ts src/gateway/routes/skills-bundled.test.ts STATUS.md passed

CI note: check is still failing only on the known non-PR formatting files, and install-smoke / Labeler failures are the same unrelated noise from PR #47.

Ready to merge from review side.

@cryptolir
cryptolir merged commit 37f9e8d into main May 24, 2026
16 of 20 checks passed
@cryptolir
cryptolir deleted the fix/skills-bundled-empty-env-fallback branch May 24, 2026 19:44
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