Skip to content

feat(client): claim a run and report its source steps and artifacts through the run client - #33

Merged
grubmeshi merged 6 commits into
mainfrom
feature/single-go-bin-runner
Nov 26, 2026
Merged

grubmeshi merged 6 commits into
mainfrom
feature/single-go-bin-runner

Conversation

@grubmeshi

@grubmeshi grubmeshi commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

What it does

This is the part of the client that the Go building block runner needs:

  • client.Client.BuildingBlockRun is a read-only run client with Claim, RegisterSource, UpdateSourceSteps, DownloadArtifact and UploadArtifact. They address a run by its uuid, because the API key of a runner may not read a run.
  • http.Error.IsTemporary tells whether an HTTP error is temporary.
  • The client retries a refused connection under every retry policy, with a warning on each retry.
  • The debug log redacts secrets in request and response bodies by JSON pointer (http.WithRedactedJsonPointers).
  • http.Error shows the body as it came. client.MeshObjectError reads the error body of meshStack. internal/oidc reads its OAuth error itself. meshstack api no longer writes the body of a failed answer to stdout.

Review carefully

client/building_block_run.go, client/building_block_run_source.go, client/http/retry.go and client/http/logging.go (redaction).

Place in the stack

6 of 6. Base: generic-mesh-object-client. The runner PR (#86) and the provider PR (#392) build on this branch.

🤖 Generated with Claude Code

@meshcloud-gh-actions

meshcloud-gh-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Coverage of the acceptance run against the meshStack backend, on ebc066e65eaef519bf1aab00859ccb2c88553b1b.

Scope Coverage
Unit tests 79.0%
Acceptance tests 56.7%
Combined 83.5%
Uncovered functions
client/api_key.go:18: MeshApiKey.meshObjectId 0.0%
client/api_key_permissions.go:20: ApiKeyPermissions.AllCodes 0.0%
client/api_key_permissions.go:33: ApiKeyPermissions.WorkspaceCodes 0.0%
client/api_key_permissions.go:263: AllApiKeyPermissions 0.0%
client/api_key_permissions.go:267: WorkspacePermissionCodes 0.0%
client/binding_status.go:18: *MeshGroupBindingStatus.WaitsForApproval 0.0%
client/binding_status.go:22: *MeshUserBindingStatus.WaitsForApproval 0.0%
client/building_block_definition.go:68: MeshBuildingBlockDefinitionApprovalPolicies.NothingRequiresApproval 0.0%
client/building_block_definition.go:79: DisabledSchedule 0.0%
client/building_block_definition.go:86: MeshBuildingBlockDefinitionSchedule.IsDisabled 0.0%
client/building_block_definition.go:90: MeshBuildingBlockDefinitionSpec.HasNeutralPolicies 0.0%
client/building_block_definition.go:94: MeshBuildingBlockDefinitionSpec.WithNeutralPolicies 0.0%
client/building_block_definition.go:148: MeshBuildingBlockDefinition.meshObjectId 0.0%
client/building_block_definition_version.go:99: MeshBuildingBlockType.TagInputTargets 0.0%
client/building_block_definition_version.go:220: MeshBuildingBlockDefinitionVersion.meshObjectId 0.0%
client/building_block_definition_version.go:223: MeshBuildingBlockDefinitionVersion.meshObjectNoSortQuery 0.0%
client/building_block_run.go:138: meshBuildingBlockRunClient.Claim 0.0%
client/building_block_run.go:158: MeshBuildingBlockRun.Abort 0.0%
client/building_block_run.go:181: MeshBuildingBlockRun.meshObjectId 0.0%
client/building_block_run_source.go:64: meshBuildingBlockRunClient.RegisterSource 0.0%
client/building_block_run_source.go:73: meshBuildingBlockRunClient.UpdateSourceSteps 0.0%
client/building_block_run_source.go:78: meshBuildingBlockRunClient.DownloadArtifact 0.0%
client/building_block_run_source.go:87: meshBuildingBlockRunClient.UploadArtifact 0.0%
client/building_block_run_source.go:98: *cappedWriter.Write 0.0%
client/building_block_runner.go:67: MeshBuildingBlockRunner.meshObjectId 0.0%
... and 71 more

covdata func names a method without its receiver, so an entry can belong to an implementation nothing selects rather than to a function the tests never reached. Open the file and line before reading one as a coverage gap.

@grubmeshi
grubmeshi force-pushed the feature/single-go-bin-runner branch from f7111e1 to 73db1b9 Compare October 13, 2026 13:52
@grubmeshi grubmeshi changed the title feat(client): publish the HTTP layer as client/http, with Basic auth feat: basic auth credential and the runner API in client Oct 13, 2026
@grubmeshi
grubmeshi force-pushed the feature/single-go-bin-runner branch from 73db1b9 to ebf91ce Compare October 13, 2026 13:58
@grubmeshi
grubmeshi force-pushed the feature/single-go-bin-runner branch 2 times, most recently from 9ab69a7 to 322b873 Compare October 15, 2026 19:18
@grubmeshi
grubmeshi force-pushed the feature/single-go-bin-runner branch 10 times, most recently from 3a034bf to eb512e3 Compare October 23, 2026 11:53
@grubmeshi grubmeshi changed the title feat: basic auth credential and the runner API in client feat: basic auth, client/http and the runner API in client Oct 23, 2026
@grubmeshi
grubmeshi force-pushed the feature/single-go-bin-runner branch 2 times, most recently from 5975d78 to 98854c7 Compare October 28, 2026 11:58
@grubmeshi
grubmeshi force-pushed the feature/single-go-bin-runner branch 3 times, most recently from abbd309 to e90226d Compare October 29, 2026 04:56
@grubmeshi grubmeshi changed the title feat: basic auth, client/http and the runner API in client feat(client): add the runner API and export the HTTP client as client/http Oct 29, 2026
@grubmeshi
grubmeshi force-pushed the feature/single-go-bin-runner branch 2 times, most recently from c85b993 to 0332c2c Compare October 30, 2026 09:04
@grubmeshi
grubmeshi force-pushed the feature/single-go-bin-runner branch 5 times, most recently from 3032cd0 to f74c926 Compare November 13, 2026 08:18
@grubmeshi
grubmeshi force-pushed the feature/single-go-bin-runner branch 2 times, most recently from d537434 to 75703bd Compare November 19, 2026 15:29
@grubmeshi
grubmeshi requested a review from j0g3sc November 19, 2026 15:41
@grubmeshi
grubmeshi force-pushed the feature/single-go-bin-runner branch from 75703bd to 52fcb6b Compare November 20, 2026 01:36

@j0g3sc j0g3sc left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is way too large to review thoroughly.
I focused on the generic client and the changes along the profile selection:

This is what i found:

profile selection:

  • Credentials can go to any host: meshstack api <full URL> takes the URL’s host as the endpoint. If credentials come from environment variables, they are sent to whatever host the URL names.
  • login hint that always fails: When no stored profile matches the endpoint, the error suggests meshstack login --endpoint X. But the login prompt rejects that command whenever any profile already exists; it needs--profile <name>added.
  • meshstack logout on a fresh setup fails: With no profiles and no endpoint it exits with an error instead of warning “Nothing to log out of”, which breaks cleanup scripts that run logout every time.

client:

  • Update can panic: MeshObjectByUuidMetadata.meshObjectId() and MeshTenant.meshObjectId() dereference a uuid without checking for nil. An object with no uuid, as a Terraform plan can produce, crashes the provider instead of returning an error.
  • Every kind now exposes Create, Update and Delete: That includes read-only kinds like event logs and runs. A call that the API doesn’t support compiles and only fails at runtime, and Delete even treats the resulting 404 as success.
  • Three clients silently moved to preview API versions: BuildingBlockDefinition and DefinitionVersion went from v1 to v1-preview, and BuildingBlockV2 from v2 to v2-preview. The commit message doesn’t mention it, and it changes what the Terraform provider sends.

claude found smaller stuff as well for other topics. I'd suggest to maybe split this PR up into chunks and make a PR stack out of it that allows a more focused review on each.

@grubmeshi
grubmeshi force-pushed the feature/single-go-bin-runner branch from 52fcb6b to ffe1302 Compare November 25, 2026 10:14
@grubmeshi
grubmeshi changed the base branch from main to generic-mesh-object-client November 25, 2026 10:14
@grubmeshi grubmeshi changed the title feat(client): export the HTTP client, add the run client and resolve the profile by endpoint feat(client): claim a run and report its source steps and artifacts through the run client Nov 25, 2026
@grubmeshi
grubmeshi added this pull request to stack #115 November 25, 2026 10:25
@grubmeshi
grubmeshi force-pushed the feature/single-go-bin-runner branch from ffe1302 to ea7f8e9 Compare November 25, 2026 11:36
grubmeshi and others added 6 commits November 25, 2026 13:12
…hrough the run client

A building block runner works with client.Client.BuildingBlockRun: Claim hands it the next run
with the run token, the inputs and the implementation, and sends the version of the HTTP
client's user agent as X-Meshcloud-Runner-Version. RegisterSource, UpdateSourceSteps,
DownloadArtifact and UploadArtifact address a run by its uuid, because the API key of a runner
may not read a run. The names follow the operations of the meshObject API.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
http.Error.IsTemporary is true for 408, 423, 429 and every 5xx, so that a caller that polls, as
a runner does for a pipeline run, knows when to go on.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A refused connection is retried under every policy and for every method, because the server received
nothing. A runner started together with meshStack then waits for its API, and a client outlasts a
restart of meshStack. Each retry logs a warning, so a person who gave a wrong endpoint sees why the
command waits and can stop it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… JSON pointer

A debug log shows a JSON body indented, with the value at each redacted JSON pointer replaced by
"[REDACTED]", and applies one-token pointers to the fields of a url-encoded form. Every request
redacts the plaintext of a secret and the clientSecret of an API key; http.WithRedactedJsonPointers
adds the tokens of an OIDC grant, the access token of an API key login and the run token of a
claimed run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…client/http

http.Error now shows the body as it came, and BodyAsJson reads it into the type the caller
expects. client.MeshObjectError reads the error body of meshStack and keeps what wraps the
http.Error, such as the authorization of a 403. internal/oidc reads its OAuth error itself.

meshstack api no longer writes the body of a failed answer to stdout; the error says what
meshStack answered.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… checkout

The Go runner clones a commit of a local repository, so the test runs a
head that is not pushed.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@grubmeshi
grubmeshi force-pushed the feature/single-go-bin-runner branch from ea7f8e9 to ebc066e Compare November 25, 2026 12:22
@sonarqubecloud

Copy link
Copy Markdown

@grubmeshi

Copy link
Copy Markdown
Collaborator Author

@j0g3sc Thanks for the review. I split the PR into a stack of six, each based on the one below it:

  1. refactor(client): move internal/http to client/http and internal/version to client/types/version #110 – client/http and client/types/version as public packages
  2. feat: resolve the profile by name, current profile or endpoint, and run without a stored one #111 – profile and endpoint resolution
  3. refactor(client): return the response body from DoRequest of client/http #112 – DoRequest returns the body, retry policy
  4. feat: read the API docs of the endpoint and keep them by their ETag #113 – API docs of the endpoint, kept by ETag
  5. refactor(client): build every kind's client on one generic MeshObjectClient and hal.Links #114 – the generic MeshObjectClient, hal.Links, action methods
  6. feat(client): claim a run and report its source steps and artifacts through the run client #33 – the run API on the run client, redaction, error body

Your findings:

Profile selection (#111)

  • Credentials can go to any host: the origin of a full URL now counts as the endpoint, exactly like --endpoint. It is an error when it differs from --endpoint or from the endpoint of a named profile. When it overrides MESHSTACK_ENDPOINT, the CLI logs a WARN line.
  • Login hint that always fails: the hint now names --profile whenever a stored profile is involved, so the suggested command works.
  • meshstack logout on a fresh setup: it warns "Nothing to log out of" and exits 0. --profile <unknown> still fails.

Client (#114)

  • Update can panic: I kept this on purpose. An object without a uuid at that point is a programming error in the caller, and the provider never calls Update or Delete before the uuid is known.
  • Every kind exposes Create, Update and Delete: there are three levels now. MeshObjectReadOnlyClient for event logs and runs, MeshObjectImmutableClient with Create and Delete for kinds without a PUT, and MeshObjectClient with Update. An unsupported call no longer compiles.
  • Preview API versions: BuildingBlockDefinition and DefinitionVersion are back on v1, BuildingBlockV2 on v2.

Base automatically changed from generic-mesh-object-client to main November 25, 2026 15:39
@grubmeshi
grubmeshi merged commit ebc066e into main Nov 26, 2026
15 of 25 checks passed
@grubmeshi
grubmeshi deleted the feature/single-go-bin-runner branch November 26, 2026 08:41
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.

3 participants