René's URL Explorer Experiment


Title: fix(static-export): GitHub writer surfaces real errors + handles empty repos by sj-unit72 · Pull Request #286 · ycode/ycode · GitHub

Open Graph Title: fix(static-export): GitHub writer surfaces real errors + handles empty repos by sj-unit72 · Pull Request #286 · ycode/ycode

X Title: fix(static-export): GitHub writer surfaces real errors + handles empty repos by sj-unit72 · Pull Request #286 · ycode/ycode

Description: Summary Hardens the REST-API GitHub writer against three related failure modes that combined to make first-publishes to a freshly-created empty repository impossible — and made any writer failure unintelligible. What was broken 1. apiError Promise stringified instead of thrown apiError is declared async, so it returns Promise. Every call site was: throw apiError('Failed to ...', res) — throwing the Promise itself, not the resolved Error. The engine's String(err) rendered every writer failure as the toast text Writer "github" failed: [object Promise], completely hiding what GitHub actually said. 2. Empty repos return 409, not 404, on GET /git/ref/heads/{branch} getBranchState only treated 404 as "branch doesn't exist yet". GitHub returns 409 Git Repository is empty for unborn-HEAD repos. Even before bug #1 was discovered, this prevented first-publishes to any repo created without an initial commit. 3. Git Data API rejects writes to unborn-HEAD repos Once #1 and #2 were fixed, the next push surfaced a fresh 409: Failed to create blob for ".../foo.webp": 409 Git Repository is empty. The blob/tree/commit endpoints all refuse to write before HEAD is born. Fix #1: await apiError(...) at all six call sites so the resolved Error is what's thrown. #2: getBranchState now treats 404 and 409 as "no branch yet". #3: New bootstrapEmptyRepo step. When branchState.exists === false, write a tiny .ycode-init file via the Contents API (PUT /repos/{owner}/{repo}/contents/.ycode-init) which is the only endpoint that initializes an empty repo. Then re-fetch branch state and proceed with the normal Git Data flow. The placeholder is immediately replaced by the real tree on the same publish (createTree runs without base_tree, so previous paths don't carry forward). Net effect: empty-repo first publishes Just Work, and any future writer failure shows GitHub's real status + message. Changes lib/apps/static-export/writers/github.ts — six await insertions, 404→404|409, new bootstrapEmptyRepo helper + call site. Compatibility Non-empty repos: zero behavior change. Bootstrap only fires when branchState.exists === false; existing repos with the configured branch hit the original updateRef path. Repos that exist but lack the configured branch: zero behavior change. That's a 404 (not 409), already handled by the existing createRef path. Bootstrap won't run because commitSha is null and we go straight to the existing branch-creation flow… wait, actually a repo with HEAD on main but missing dev would 404. Bootstrap would PUT .ycode-init to dev, creating the branch with one extra commit before the real export commit. That's slightly chattier than necessary but functionally correct — first publish to a fresh branch on an existing repo still works. All existing successful publishes (the path Grish has been using for months): byte-identical. Test plan Connect Ycode to a brand-new empty GitHub repo (no README, no init). Run Export Now. Repo gets .ycode-init + real export tree in two commits, branch is created at main. Run Export Now again. Single commit overwrites previous tree, .ycode-init gone. Same flow against an existing, non-empty repo with the configured branch already present (regression check). Works as before. Deliberately use a bad token. Toast shows real GitHub 401 / 403 message instead of [object Promise]. npm run type-check clean. Verified end-to-end Self-hosted Ycode instance built from this branch, pointed at a brand-new empty sj-unit72/grishmusic-com-v2-style repo: first publish succeeded, subsequent publishes succeeded, repo history shows the bootstrap commit followed by the export commits as expected.

Open Graph Description: Summary Hardens the REST-API GitHub writer against three related failure modes that combined to make first-publishes to a freshly-created empty repository impossible — and made any writer failure u...

X Description: Summary Hardens the REST-API GitHub writer against three related failure modes that combined to make first-publishes to a freshly-created empty repository impossible — and made any writer failure u...

Opengraph URL: https://github.com/ycode/ycode/pull/286

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:7dbb8930-5965-a0f6-abbc-0dedc33c39fa
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idB2E4:DDED5:AB0D5:E6947:6AFE43A2
html-safe-nonce6eb4324f93429a8edececd466ae6259bc52da4d83cc4fe6f2dee0d50167aa5e6
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMkU0OkRERUQ1OkFCMEQ1OkU2OTQ3OjZBRkU0M0EyIiwidmlzaXRvcl9pZCI6IjI2MDk1NTEyNDI0MDk0Mjc4NzQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac57488edcf0a500bdb955fa0d05e99d92eb5f052b90b2867e78edb906026804d4
hovercard-subject-tagpull_request:3759110024
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/ycode/ycode/pull/286/files
twitter:imagehttps://avatars.githubusercontent.com/u/19424303?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/19424303?s=400&v=4
og:image:altSummary Hardens the REST-API GitHub writer against three related failure modes that combined to make first-publishes to a freshly-created empty repository impossible — and made any writer failure u...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Nonef1a5901e2377b0af2a0b303f9528678f1475d04b9219dca1e993344196eaa07c
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/ycode/ycode git https://github.com/ycode/ycode.git
octolytics-dimension-user_id65892203
octolytics-dimension-user_loginycode
octolytics-dimension-repository_id1165452593
octolytics-dimension-repository_nwoycode/ycode
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id1165452593
octolytics-dimension-repository_network_root_nwoycode/ycode
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasece393ea11ad276623b946bc9663d3e7d6f564275
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/ycode/ycode/pull/286/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fycode%2Fycode%2Fpull%2F286%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fycode%2Fycode%2Fpull%2F286%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=ycode%2Fycode
Reloadhttps://github.com/ycode/ycode/pull/286/files
Reloadhttps://github.com/ycode/ycode/pull/286/files
Reloadhttps://github.com/ycode/ycode/pull/286/files
ycodehttps://github.com/ycode
ycodehttps://github.com/ycode/ycode
Codehttps://github.com/ycode/ycode
Issues7 (7)https://github.com/ycode/ycode/issues
Pull requests1 (1)https://github.com/ycode/ycode/pulls
Discussionshttps://github.com/ycode/ycode/discussions
Actionshttps://github.com/ycode/ycode/actions
Projectshttps://github.com/ycode/ycode/projects
Security and quality1 (1)https://github.com/ycode/ycode/security
Insightshttps://github.com/ycode/ycode/insights
Sign up for GitHub https://github.com/signup?return_to=%2Fycode%2Fycode%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fycode%2Fycode%2Fissues%2Fnew%2Fchoose
tristan-mouchethttps://github.com/tristan-mouchet
ycode:develophttps://github.com/ycode/ycode/tree/develop
sj-unit72:fix/static-export-github-writer-awaithttps://github.com/sj-unit72/ycode/tree/fix/static-export-github-writer-await
Conversation 0 https://github.com/ycode/ycode/pull/286
Commits 2 https://github.com/ycode/ycode/pull/286/commits
Checks 0 https://github.com/ycode/ycode/pull/286/checks
Files changed https://github.com/ycode/ycode/pull/286/files
Please reload this pagehttps://github.com/ycode/ycode/pull/286/files
fix(static-export): GitHub writer surfaces real errors + handles empty repos https://github.com/ycode/ycode/pull/286/files#top
Show all changes 2 commits https://github.com/ycode/ycode/pull/286/files
30bf55e fix(static-export): render htmlEmbed inline instead of iframe sj-unit72 May 27, 2026 https://github.com/ycode/ycode/pull/286/commits/30bf55ec1d5bb32c047afabadf5ad3983b772d2c
850bf75 fix(static-export): GitHub writer surfaces real errors + handles empt… sj-unit72 May 28, 2026 https://github.com/ycode/ycode/pull/286/commits/850bf752d571579bdbf73762580335b0363ab064
Clear filters https://github.com/ycode/ycode/pull/286/files
Please reload this pagehttps://github.com/ycode/ycode/pull/286/files
Please reload this pagehttps://github.com/ycode/ycode/pull/286/files
document.ts https://github.com/ycode/ycode/pull/286/files#diff-0bcbcbe7801b0e38ffba7132985c78f9025d675f44dda5695564d4a973541c62
github.ts https://github.com/ycode/ycode/pull/286/files#diff-6e100f00722a47f045a6e7a9905a887e2309725007b2160ea565ca9a14796623
page-fetcher.ts https://github.com/ycode/ycode/pull/286/files#diff-28e0b23fdbe1ae4953b860f3213a935ad8d5a4c9102c3ac6180a859ae29b3f99
https://github.com/ycode/ycode/blob/develop/.github/CODEOWNERS#L1
lib/apps/static-export/document.tshttps://github.com/ycode/ycode/pull/286/files#diff-0bcbcbe7801b0e38ffba7132985c78f9025d675f44dda5695564d4a973541c62
View file https://github.com/sj-unit72/ycode/blob/850bf752d571579bdbf73762580335b0363ab064/lib/apps/static-export/document.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/ycode/ycode/pull/286/{{ revealButtonHref }}
https://github.com/ycode/ycode/pull/286/files#diff-0bcbcbe7801b0e38ffba7132985c78f9025d675f44dda5695564d4a973541c62
https://github.com/ycode/ycode/pull/286/files#diff-0bcbcbe7801b0e38ffba7132985c78f9025d675f44dda5695564d4a973541c62
https://github.com/ycode/ycode/blob/develop/.github/CODEOWNERS#L1
lib/apps/static-export/writers/github.tshttps://github.com/ycode/ycode/pull/286/files#diff-6e100f00722a47f045a6e7a9905a887e2309725007b2160ea565ca9a14796623
View file https://github.com/sj-unit72/ycode/blob/850bf752d571579bdbf73762580335b0363ab064/lib/apps/static-export/writers/github.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/ycode/ycode/pull/286/{{ revealButtonHref }}
https://github.com/ycode/ycode/pull/286/files#diff-6e100f00722a47f045a6e7a9905a887e2309725007b2160ea565ca9a14796623
https://github.com/ycode/ycode/pull/286/files#diff-6e100f00722a47f045a6e7a9905a887e2309725007b2160ea565ca9a14796623
https://github.com/ycode/ycode/pull/286/files#diff-6e100f00722a47f045a6e7a9905a887e2309725007b2160ea565ca9a14796623
https://github.com/ycode/ycode/pull/286/files#diff-6e100f00722a47f045a6e7a9905a887e2309725007b2160ea565ca9a14796623
https://github.com/ycode/ycode/pull/286/files#diff-6e100f00722a47f045a6e7a9905a887e2309725007b2160ea565ca9a14796623
https://github.com/ycode/ycode/pull/286/files#diff-6e100f00722a47f045a6e7a9905a887e2309725007b2160ea565ca9a14796623
https://github.com/ycode/ycode/pull/286/files#diff-6e100f00722a47f045a6e7a9905a887e2309725007b2160ea565ca9a14796623
https://github.com/ycode/ycode/pull/286/files#diff-6e100f00722a47f045a6e7a9905a887e2309725007b2160ea565ca9a14796623
https://github.com/ycode/ycode/pull/286/files#diff-6e100f00722a47f045a6e7a9905a887e2309725007b2160ea565ca9a14796623
https://github.com/ycode/ycode/pull/286/files#diff-6e100f00722a47f045a6e7a9905a887e2309725007b2160ea565ca9a14796623
https://github.com/ycode/ycode/pull/286/files#diff-6e100f00722a47f045a6e7a9905a887e2309725007b2160ea565ca9a14796623
https://github.com/ycode/ycode/pull/286/files#diff-6e100f00722a47f045a6e7a9905a887e2309725007b2160ea565ca9a14796623
https://github.com/ycode/ycode/blob/develop/.github/CODEOWNERS#L1
lib/page-fetcher.tshttps://github.com/ycode/ycode/pull/286/files#diff-28e0b23fdbe1ae4953b860f3213a935ad8d5a4c9102c3ac6180a859ae29b3f99
View file https://github.com/sj-unit72/ycode/blob/850bf752d571579bdbf73762580335b0363ab064/lib/page-fetcher.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/ycode/ycode/pull/286/{{ revealButtonHref }}
https://github.com/ycode/ycode/pull/286/files#diff-28e0b23fdbe1ae4953b860f3213a935ad8d5a4c9102c3ac6180a859ae29b3f99
https://github.com/ycode/ycode/pull/286/files#diff-28e0b23fdbe1ae4953b860f3213a935ad8d5a4c9102c3ac6180a859ae29b3f99
https://github.com/ycode/ycode/pull/286/files#diff-28e0b23fdbe1ae4953b860f3213a935ad8d5a4c9102c3ac6180a859ae29b3f99
https://github.com/ycode/ycode/pull/286/files#diff-28e0b23fdbe1ae4953b860f3213a935ad8d5a4c9102c3ac6180a859ae29b3f99
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.