Repository navigation
feat(sdk): read the log of a build - #11
Merged
Merged
Conversation
A failed build carries a one-line reason; its log says the rest. The API
already serves it at GET /api/cloud/builds/{buildId}/logs, under the same
contract as a service's logs: server-sent log events with a cursor, a tail
of the newest lines when the read does not follow.
- spec: streamBuildLogs, in its own part file (builds.yaml)
- CloudApi.buildLogs(buildId, { follow, limit, lastEventId, onOpen })
- the request shapes move to logs.ts; a service's log read is unchanged
Co-Authored-By: Claude <noreply@anthropic.com>
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.
What
CloudApi.buildLogs(buildId, request)reads the output of one build, and the public spec gains the operation it calls,streamBuildLogs(GET /api/cloud/builds/{buildId}/logs).A failed build carries a one-line reason (
builds[].failureReason). Its log says the rest: which step, which package, which line. The API already serves that log to the console; it was missing from the public contract, so a client built on the SDK could only show the one line.Contract, as the server implements it
log({ at, level, message, instance }, the event id is the cursor), thenend;errorwith acodewhen the platform cannot serve the stream.follow, the read is a tail: the newest lines, oldest first, 500 at most. Read from the start, it opens with oneBuild recipe: ...line that has no cursor and does not count towardslimit.Last-Event-ID, the read resumes after that event, oldest first.cloud.errors.builds.not_found: an unknown build, a build of another workspace, and a build whose service was removed.Changes
sdk/openapi/builds.yaml: the operation, in its own part file; one$refline in the root spec.sdk/src/logs.ts:LogRequestmoves here fromapi.ts, next to the newBuildLogRequest(limitadded) and the one function that turns a request into its query and headers.CloudApi.logssends exactly what it sent before.sdk/src/api.ts:buildLogs.sdk/test/builds.test.ts: the request a bounded read, a resumed follow and a plain read send; the events yielded in order;onOpenbefore the first line; the 404 as aCloudApiError; and a service's log read unchanged.Checked
pnpm --dir sdk test: 46 tests pass, 5 of them new.pnpm run checks). On my Windows checkout three steps fail for reasons outside this change: the format check reads CRLF working files (the index is LF, and the changed files passoxfmt --check), the CLI's Ctrl+C test expects exit code 130, and the sync check wants symlinks.cloud.errors.builds.not_found.Release
Needs a release of
@antelopejs/cloud-sdkbefore a client can depend on it.