Skip to content

feat: capture a failed composed child's run log via the run token#220

Open
grubmeshi wants to merge 2 commits into
mainfrom
feature/composed-run-failure-logs
Open

feat: capture a failed composed child's run log via the run token#220
grubmeshi wants to merge 2 commits into
mainfrom
feature/composed-run-failure-logs

Conversation

@grubmeshi

@grubmeshi grubmeshi commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Capture a failed composed child's run log via the run token

Pairs with the meshfed-release PR on the identically-named branch feature/composed-run-failure-logs.

Why

When a composition building block (e.g. a starter kit) waits on a child building block it created and that
child fails, addRunFailureDiagnostics fetches the child run's logs and adds the failing step as an error, so
the tf-block-runner streams the real error into the parent run's log. Fetched with the consumer's workspace
credentials, a child with run_transparency = false returns no systemMessage, so the parent log only carried
a generic "run failed". meshStack injects a privileged, run-scoped token (MESHSTACK_RUN_TOKEN) into such runs
that can read the composition's own children's runs.

Change

  • provider.go: read MESHSTACK_RUN_TOKEN (env-only — it is set per run by the platform, never in HCL); when
    present, build a run-token-authorized run-log client.
  • client.go: NewBuildingBlockRunClientWithAuth builds a standalone MeshBuildingBlockRunClient with its own
    authorization (skipping the version check the main client already did). New Client.BuildingBlockRunWithRunToken
    field, nil unless the token is set.
  • building_block_resource.go: addRunFailureDiagnostics fetches the failed run's logs with the run-token
    client when available, else the workspace client. Everything else (CRUD, polling) keeps the workspace
    credentials.

The child run uuid the provider polls comes from bb.Status.LatestRunUuid, which the paired backend change
now exposes to the block owner regardless of the child's run transparency.

Additive on a -preview API — not breaking, no TerraformProviderVersionRequirements.kt coordination needed.

Tests

  • Unit (building_block_resource_await_test.go): addRunFailureDiagnostics uses the run-token client when
    configured (and not the workspace client), and falls back to the workspace client when it is not; the fetched
    system message reaches the diagnostics. Hermetic, CI-runnable.
  • End-to-end is verified by hand with a local scratch demo (a composition against a local stack with one child
    forced to fail at run_transparency = false); it is not automated because CI runs the tf-block-runner as a
    service container that pulls the released provider from the registry, so it cannot exercise a dev-built
    provider. Wiring the dev provider into the local runner requires a dev_overrides block in $HOME/.terraformrc
    (the runner strips TF_CLI_CONFIG_FILE).

task test and task lint green. CHANGELOG.md: new v0.23.1 FEATURES entry.

Cross-repo PR

  • meshcloud/meshfed-release#10286 — backend changes (A: expose run identifiers to the block owner; B: run token for sync API runs).

When a composition waits on a child building block that fails, fetch the
failed run's logs with the run-scoped MESHSTACK_RUN_TOKEN (env-only) when
present, so the child's system message is captured into the parent run
even if the child has run transparency disabled. Falls back to the
workspace credentials when no run token is set.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown

📊 Test Coverage

Scope Coverage
Unit tests (mock client) 74.8%
Combined (unit + acceptance) 80.4% — ✅ acceptance passed
Uncovered functions (combined run)
github.com/meshcloud/terraform-provider-meshstack/client/api_key_permissions.go:225:							AllApiKeyPermissions				0.0%
github.com/meshcloud/terraform-provider-meshstack/client/buildingblock.go:97:								Delete						0.0%
github.com/meshcloud/terraform-provider-meshstack/client/client.go:52:									NewApiTokenAuthorization			0.0%
github.com/meshcloud/terraform-provider-meshstack/client/client.go:110:									NewBuildingBlockRunClientWithAuth		0.0%
github.com/meshcloud/terraform-provider-meshstack/client/internal/logging.go:27:							Debug						0.0%
github.com/meshcloud/terraform-provider-meshstack/client/internal/logging.go:31:							Info						0.0%
github.com/meshcloud/terraform-provider-meshstack/client/internal/logging.go:35:							Warn						0.0%
github.com/meshcloud/terraform-provider-meshstack/client/internal/retry.go:228:								Close						0.0%
github.com/meshcloud/terraform-provider-meshstack/client/internal/retry.go:249:								Write						0.0%
github.com/meshcloud/terraform-provider-meshstack/client/project_group_binding.go:27:							Read						0.0%

Combined with go tool covdata merge over the unit and acceptance coverage data. The acceptance suite runs ./internal/provider against the live backend; coverage is attributed across all packages (-coverpkg=./...).

A meshstack_building_block_definition with an empty version_spec.inputs = {}
failed with "Provider produced inconsistent result after apply": the backend
collapses a null and an empty inputs map, and the read-back only restored a
null shape, so an empty map became null. Preserve the caller's exact shape
(nil stays nil, {} stays {}) when the version carries no inputs, on apply and
on refresh.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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