Skip to content

Fix sync bugs and fail runs on Teamwork errors - #76

Open
marcizhu wants to merge 8 commits into
test-against-mock-teamworkfrom
fix-sync-bugs
Open

marcizhu wants to merge 8 commits into
test-against-mock-teamworkfrom
fix-sync-bugs

Conversation

@marcizhu

Copy link
Copy Markdown
Member

Stack: 1. #75 tests → 2. #76 bug fixes → 3. #77 link matching → 4. #78 secrets → 5. #79 test mode removal

Summary

Fixes one bug per commit: comments with quotes or backslashes were mangled or rejected, tasks linked twice were updated twice, an ignored project stopped the remaining tasks, # comments in code blocks became headings, and the required-variable check crashed. Failed Teamwork requests (wrong token, inaccessible task, outage) now fail the run instead of passing silently, and ignored events no longer call the API. It also removes four unused functions. Merge #77 right after this one: until then, text that only looks like a task link (subtasks/5) gets a 404 and fails the run.

Evidence

Snapshot changes from ./tests/run.sh --update at each commit:

  • Before: opened-lightweight: the title's quotes are stripped and the \t in C:\temp became a tab.
    body: "PR [**Handle null in C:\temp**](…) opened by **octocat**"
    
    After:
    body: "PR [**\"Handle \"null\" in C:\\temp\"**](…) opened by **octocat**"
    
  • Before: opened, closed-*, review-approved*: multi-line comments are invalid JSON (-> 400). The mock is stricter than Teamwork about raw newlines; backslashes break Teamwork too.
    After: -> 201 with the full body.
  • Before: task-links processes task 1001 three times. After: once.
  • Before: ignored-project stops at the ignored task. After: task 1002 is commented on.
  • Before: opened turns # configure the "client" secret inside a code block into a #### heading. After: left alone.
  • Before: unsupported-event looks the task up. After: no requests.
  • Before: wrong-token: exit code: 0, carrying on after the 401. After:
    exit code: 1
    
    stderr:
      curl: (22) The requested URL returned error: 401
      Failed to get the project of task 1001, check the task exists and the API token's user can access it
      1 Teamwork request(s) failed, see the errors above
    
  • Before: an empty GITHUB_REPOSITORY fails with echoerr: command not found (exit 127); an unset one with !1: unbound variable. After: The env variable GITHUB_REPOSITORY is required. (exit 1), checked by hand against the image. GITHUB_EVENT_NAME is now checked too.

🤖 Generated with Claude Code

marcizhu and others added 8 commits October 20, 2026 19:53
The comment JSON was assembled by string interpolation, with only double
quotes stripped. Backslashes made the payload invalid (C:\Users, \d+, a
trailing \), so the comment was rejected, and \n or \u0022 were
reinterpreted. Stripping quotes also removed them from PR titles, bodies
and review text, including the quotes the lightweight comments put
around the title.

Let jq escape the body instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A task linked more than once, e.g. in a Markdown link whose text is
also the URL, got one comment, tag and stage move per link.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The IGNORE_PROJECT_IDS check exited the whole run, so tasks linked after
one in an ignored project were never processed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The H1-H3 rewrite in the PR body also turned comment lines in fenced
code blocks (shell, Python, YAML...) into #### headings. Track fences
with awk and only rewrite lines outside them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Nothing calls ensure::total_args, github::get_pr_number,
github::get_repository_full_name or github::print_all_data.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
It called echoerr, which doesn't exist, so an empty variable failed with
"command not found" (exit 127), and an unset one hit set -u ("unbound
variable") before the check ran. Also check GITHUB_EVENT_NAME, which the
action relies on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Unsupported events looked up every linked task before giving up. Decide
on the handler first, so they make no API calls. The next commit relies
on this so that failed lookups can't fail runs for events the action
ignores.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
curl ran without --fail, so HTTP errors (a revoked token, a task the
token can't see, a Teamwork outage) were only logged and the run still
passed. A failed task lookup also carried on with "null" as the project
id. Network errors, on the other hand, aborted the run halfway, and a
hung API held the runner until the job timed out.

Pass --fail-with-body and --max-time 30, log what failed, carry on with
the other steps and tasks, then exit 1 if anything failed.

Co-Authored-By: Claude Opus 5.5 <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.

2 participants