mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 09:25:06 +03:00
fix(www): keep committed agent-skills index when fetch fails outside production (#50556)
## I have read the [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) file. YES ## What kind of change does this PR introduce? Bug fix (build resilience) ## What is the current behavior? `apps/www/scripts/fetchAgentSkills.mjs` runs as part of `content:build` and fails the whole `www` build (and `pnpm dev:www`) whenever the GitHub API call fails. #50106 added `AGENT_SKILLS_GITHUB_TOKEN` to mitigate rate limits on Vercel, but that does not cover local runs or builds where the env var is not available (e.g. fork PRs). Example from a local `pnpm dev:www` hitting the unauthenticated rate limit: ``` www:dev: Error: GET https://api.github.com/repos/supabase/agent-skills/releases/latest → 403 www:dev: at fetchJson (file:///.../apps/www/scripts/fetchAgentSkills.mjs:38:22) www:dev: at process.processTicksAndRejections (node:internal/process/task_queues:105:5) www:dev: at async main (file:///.../apps/www/scripts/fetchAgentSkills.mjs:53:19) ``` ## What is the new behavior? `public/.well-known/agent-skills/index.json` is already committed to the repo, so when the fetch fails and `VERCEL_ENV` is not `production`, the script logs the error, keeps the committed file, and exits 0: ``` www:dev: Error: GET https://api.github.com/repos/supabase/agent-skills/releases/latest → 403 www:dev: ... www:dev: Fetch failed — keeping committed public/.well-known/agent-skills/index.json ``` Production builds still fail loudly so a stale skills list is never silently shipped. Verified locally by forcing a 401 with a bad token: - `VERCEL_ENV=preview` exits 0 and keeps the committed `index.json` - `VERCEL_ENV=production` exits 1 ## Additional context Follow-up to #50106. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved handling of skill data fetch failures outside production. * Preserves previously available skill data when a fetch fails and a committed fallback is available. * Continues to report failures when no fallback data exists. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
1 parent
2cb70302b0
commit
8696762b4b
1 file changed
+11
-1
@@ -10,9 +10,12 @@
|
||||
* Spec: https://github.com/agentskills/agentskills/pull/254
|
||||
* Uses AGENT_SKILLS_GITHUB_TOKEN if set to avoid GitHub's unauthenticated
|
||||
* rate limit (60 req/hr per IP, shared across Vercel build machines).
|
||||
*
|
||||
* If the fetch fails outside production, the committed index.json is kept so
|
||||
* preview and local builds don't break on GitHub rate limits.
|
||||
*/
|
||||
|
||||
import { promises as fs } from 'node:fs'
|
||||
import { existsSync, promises as fs } from 'node:fs'
|
||||
import { dirname, join } from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
@@ -50,5 +53,12 @@ async function main() {
|
||||
|
||||
main().catch((err) => {
|
||||
console.error(err)
|
||||
const canFallBack = process.env.VERCEL_ENV !== 'production'
|
||||
const hasPreviousWrite = existsSync(join(OUT_DIR, 'index.json'))
|
||||
|
||||
if (canFallBack && hasPreviousWrite) {
|
||||
console.warn('Done — keeping committed public/.well-known/agent-skills/index.json')
|
||||
process.exit(0)
|
||||
}
|
||||
process.exit(1)
|
||||
})
|
||||
Reference in new issue
Block a user