fix: increase execution limits and pass them to server dispatch #2
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
riley/codetether-action!2
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/silent-partial-completion"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Server-dispatched tasks were running out of execution budget before pushing commits. Issue #505 on spotlessbinco completed (status: completed) but output was truncated mid-sentence and branch was never pushed.
Changes
max_stepsandtask_timeout_secondsin the task dispatch metadata so the server-side agent uses the caller's execution budget instead of server defaultsTest Plan
Code Review
This pull request significantly enhances the CodeTether GitHub Action by introducing robust logging, artifact persistence, and a "fail closed" mechanism. It adds a local-mode issue handler that automates the branch-edit-commit-push-PR workflow and improves error handling across both local and server modes. Key additions include a log directory for artifact uploads, structured logging functions, and a job summary written to GITHUB_STEP_SUMMARY. Feedback focuses on improving the reliability of the shell scripts: logging functions should output to stderr to prevent polluting captured stdout in subshells, and temporary files for API responses should use mktemp to avoid collisions. Additionally, suggestions were made to handle empty API responses safely when piping to jq and to use character-aware parameter expansion for string truncation to prevent splitting multi-byte UTF-8 characters.
@ -39,6 +39,12 @@ mkdir -p "${CODETETHER_ARTIFACT_DIR}"# Touch the log file so it always exists: > "${CODETETHER_LOG_FILE}"Logging functions should direct their output to stderr. Currently,
log_infoand the::error::command inlog_erroroutput to stdout. If these functions are called within a subshell whose stdout is captured (for example,resp=$(github_api_post ...)), the log messages will be included in the captured variable, which will likely cause subsequent JSON parsing withjqto fail.Using a fixed path like
/tmp/codetether-gh-response.jsonfor API responses can lead to collisions or permission issues if multiple instances of the action run in the same environment. It is safer to usemktempto create a unique temporary file and ensure it is removed after use.If the
responsevariable is empty (e.g., if the API call failed),echo "$response"will produce a newline, which causesjqto fail with a parse error. Using${response:-{}}provides a safe default forjqto process.@ -0,0 +42,4 @@local ec=$?checkpoint "handle_issue_local: AFTER run_local_codetether — exit_code=${ec}"local review_textreview_text=$(head -c 65000 "$output_file")Using
head -cto truncate output can split multi-byte UTF-8 characters, which may result in invalid strings that the GitHub API might reject. A safer way to truncate strings in Bash (which is character-aware) is using parameter expansion.Pull request overview
Updates the CodeTether GitHub Action to reduce server-mode truncation/timeouts by increasing execution budgets and ensuring those budgets are passed through in server task dispatch metadata. It also adds more robust diagnostics/log persistence and improves failure handling for local/server flows.
Changes:
max_stepsto 50,task_wait_secondsto 3600) and document applicability to server+local.max_stepsandtask_timeout_secondsin server dispatch metadata and improve server polling/dispatch logging + artifact capture.Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
fail_on_errorinput andtask_idoutput, uploads logs artifact..codetether-agent/.Comments suppressed due to low confidence (1)
action/lib/server.sh:150
poll_task_resultnow returns from each branch, but theexport TASK_STATUSafter theif/elif/elseis unreachable. Removing the dead code (or moving the export before returning) will make the control flow clearer.💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
@ -39,6 +39,12 @@ mkdir -p "${CODETETHER_ARTIFACT_DIR}"# Touch the log file so it always exists: > "${CODETETHER_LOG_FILE}"log_erroremits a GitHub Actions workflow command (::error::) using the raw message. If the message contains newlines,%, or sequences like::add-mask::(which can come from untrusted issue/PR content or server responses), this can break log formatting or enable workflow-command injection. Escape the message per GitHub command spec (%, \r, \n) before printing::error::..., or avoid emitting workflow commands for untrusted text.GitHub API branch endpoints require URL-encoding branch names. Using
/branches/${branch}will fail for common branch names that contain/(e.g.feature/fooorcodetether/issue-123), causing push verification to report a mismatch even when the push succeeded. URL-encodebranchbefore building the API path (or use an API that accepts refs safely).Same URL-encoding issue here:
/repos/.../branches/${branch}will 404 for branches with/, and the function will then compare an emptyactual_shaand fail verification. Encodebranch(or fetch the ref viagit ls-remote/ an API endpoint where the ref is a query parameter) before callinggithub_api_get.@ -24,13 +27,14 @@ run_local_codetether() {# ── Gather PR diff, truncated to MAX_DIFF_LINES ──────────────────gather_diff() {echo "::group::Fetching PR diff"checkpoint "local: BEFORE gather_diff"The review prompt now embeds triple backticks (```diff) inside a double-quoted string. In bash, backticks trigger command substitution even inside double quotes, so this can try to execute the contents between backticks and/or break the assignment. Use escaped backticks (```) again, or switch to a heredoc (cat <<'EOF' ... EOF) to include literal backticks safely.
build_metadata_jsonusesjq --argjsonformax_stepsandtask_timeout_seconds, but these values come from action inputs (strings) and will causejqto fail if a user supplies a non-integer (e.g. "50\n" or "1h"). Consider validating/coercing to an integer (e.g.tonumber) and/or failing with a clear error message before dispatching.🔍 Debug Checkpoints Added (
ce51f47)This commit adds 88 checkpoint calls across all shell scripts to create a detailed breadcrumb trail in the GitHub Actions logs.
What was added
Core infrastructure (
common.sh):checkpoint()function — logs timestamp, elapsed seconds, remaining time budget at every stepemergency_push_and_exit()— force-pushes current state when time budget is exhaustedCODETETHER_START_EPOCH/CODETETHER_TIME_BUDGET— shared timing statefinalize_run()with total elapsed timeCoverage (88 checkpoints total):
entrypoint.shissue.shgithub.shserver.shlocal.shWhat each checkpoint shows
Time budget alerts
This should make it immediately obvious where the action spends its time and where it gets stuck or times out.
Closing this PR — it has merge conflicts with main (PR #1 was squash-merged, creating a divergent base). Also the CI run failed due to a shellcheck parse error in the CODETETHER_TIME_BUDGET arithmetic expression. I've created a clean replacement branch that resolves both issues.
Pull request closed