Skip to content

workspace-quarto-site: make preview-comment read genuinely best-effort - #92

Closed
gas2own wants to merge 1 commit into
mainfrom
fix-preview-comment-best-effort
Closed

workspace-quarto-site: make preview-comment read genuinely best-effort#92
gas2own wants to merge 1 commit into
mainfrom
fix-preview-comment-best-effort

Conversation

@gas2own

@gas2own gas2own commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Problem

The reusable Quarto docs deploy step runs under bash -e. Its PR preview-comment block is explicitly meant to be best-effort — the comment even says "a comment hiccup shouldn't fail an otherwise-successful publish" — and its two write calls (PATCH/POST) are guarded with || echo "::warning::…".

But the read that seeds existing was an unguarded command substitution:

existing=$(gh api "repos/.../issues/$PR_NUMBER/comments" --jq '')

When gh api gets a transient HTML 5xx error page instead of JSON, it exits non-zero and prints invalid character '<' looking for beginning of value. Under set -e, that failed substitution aborts the whole deploy job with exit 1 — even though gh-pages was already published successfully.

Observed live on a freshly-scaffolded workspace repo during a brief GitHub API blip: the site deployed fine (gh-pages already up to date), then the job went red on the comment read.

Fix

Guard the read the same way the writes are guarded: redirect stderr, swallow the non-zero exit, emit a ::warning::, and continue with an empty existing (which falls through to the create branch, itself already guarded). Now a flaky GitHub API only costs the preview comment, not the deploy status.

🤖 Generated with Claude Code

The deploy step runs under `set -e`. The PR preview-comment block is meant
to be best-effort ("a comment hiccup shouldn't fail an otherwise-successful
publish"), and its two write calls are guarded with `|| echo ::warning`.
But the read that seeds `existing` — an unguarded command substitution —
was not. When `gh api` gets a transient HTML 5xx error page instead of JSON
(observed as `invalid character '<' looking for beginning of value`), the
substitution returns non-zero and `set -e` aborts the whole deploy job,
even though gh-pages was already published successfully.

Guard the read the same way: swallow the failure, emit a warning, and
continue with an empty `existing` (falls through to the create branch,
itself already guarded). Now a flaky GitHub API only costs the comment,
not the deploy status.
gas2own added a commit that referenced this pull request Jul 16, 2026
…ct URL on private repos)

Two latent bugs in the reusable Quarto deploy workflow made a freshly
scaffolded repo's first PR look broken (red deploy check, no/wrong preview
link) even when the site published fine:

1. The preview-comment gh api read was unguarded under set -e; a transient
   5xx HTML body breaks --jq and abORTS the deploy after publish. Now the
   block runs under set +e and closes on a guaranteed-success command.
2. The preview URL was hardcoded to <owner>.github.io/<repo>, dead on
   private/internal repos that serve from an obfuscated *.pages.github.io
   domain. Now resolved from the Pages API with fallback; deploy job and
   scaffold docs.yml template grant pages: read.

Supersedes #91, #92, #93.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@gas2own

gas2own commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #94, which consolidates this preview-comment robustness fix (and adds the private-repo preview-URL fix) into a single PR. Closing to keep the review surface to one PR.

@gas2own gas2own closed this Jul 17, 2026
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