fix(search-index): use portable URL ids and automate CI rebuild#472
fix(search-index): use portable URL ids and automate CI rebuild#472vipulpandey21 wants to merge 1 commit into
Conversation
✅ Deploy Preview for krkn-chaos ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
Review Summary by QodoFix search index portable IDs and automate CI rebuild
WalkthroughsDescription• Fix hardcoded machine-specific paths in search index document IDs - Replace absolute filesystem paths with portable relative URLs • Automate search index regeneration in CI workflow - Add Node.js setup and build step to rebuild index on content changes - Commit regenerated index back to main branch • Prevent accidental commits of locally-built search index - Add static/search-index.json to .gitignore - CI uses git add -f to intentionally track canonical version • Demote Netlify API reload to non-fatal operation - Static file now source of truth instead of serverless function Diagramflowchart LR
A["Markdown content files"] -->|"build-search-index.js"| B["Search index with portable URLs"]
B -->|"CI workflow"| C["static/search-index.json"]
C -->|"git commit + push"| D["Repository main branch"]
D -->|"runtime fetch"| E["Chatbot DocumentationIndex.js"]
E -->|"search results"| F["AI Assistant"]
File Changes1. scripts/build-search-index.js
|
Code Review by Qodo
Context used✅ Compliance rules (platform):
24 rules 1. Stale index after merge
|
|
|
||
| const document = { | ||
| id: filePath, | ||
| id: url, |
There was a problem hiding this comment.
1. Stale index after merge 🐞 Bug ≡ Correctness
The generator now emits portable IDs (id: url), but the committed static/search-index.json in this branch still contains absolute /Users/... IDs; merging this PR alone will not necessarily rebuild that file because the workflow only triggers on content/en/**/*.md changes. This leaves the production-served index polluted/stale until the next docs content change or a manual run that rebuilds and commits the file.
Agent Prompt
## Issue description
`scripts/build-search-index.js` now correctly sets `document.id = url`, but the tracked `static/search-index.json` currently checked into this branch still contains absolute machine paths. Because the rebuild workflow is path-filtered to only run on documentation markdown changes, merging this PR without any `content/en/**/*.md` change will not automatically regenerate and commit the corrected index.
## Issue Context
- Runtime loads `/search-index.json` from the deployed site; if the tracked file stays polluted, search continues to serve bad IDs.
- Current workflow trigger is restricted to `content/en/**/*.md`.
## Fix Focus Areas
- Regenerate and commit `static/search-index.json` in this PR (force-add since it’s gitignored), **and/or**
- Expand workflow `on.push.paths` to include `scripts/build-search-index.js` (and any other generator inputs) so merging this PR triggers a rebuild.
### References
- .github/workflows/rebuild-docs-index.yml[8-13]
- scripts/build-search-index.js[52-66]
- static/search-index.json[1-22]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| - name: Install dependencies | ||
| run: npm ci | ||
|
|
There was a problem hiding this comment.
2. Npm ci likely fails 🐞 Bug ☼ Reliability
The workflow runs npm ci, but the repository ignores package-lock.json, which makes a lockfile unlikely to be present in the checkout and can cause the install step to fail. If dependency install fails, the CI job will never rebuild/commit static/search-index.json.
Agent Prompt
## Issue description
The rebuild workflow uses `npm ci`, which requires a committed lockfile. This repo’s `.gitignore` ignores `package-lock.json`, so `npm ci` is at high risk of failing on GitHub Actions runners.
## Issue Context
The index rebuild step (`node scripts/build-search-index.js`) depends on Node dependencies from the root `package.json`. If `npm ci` fails, the workflow cannot rebuild or commit the updated index.
## Fix Focus Areas
- Either commit a root `package-lock.json` and stop ignoring it, or
- Change the workflow step from `npm ci` to `npm install` (less deterministic but compatible with no lockfile).
### References
- .github/workflows/rebuild-docs-index.yml[35-47]
- .gitignore[15-22]
- package.json[9-46]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
ed6e5dc to
2a65215
Compare
2a65215 to
d594fc0
Compare
The committed static/search-index.json contained absolute filesystem paths from a specific developer's machine (/Users/sahil/website-1/...) baked into every document id field, and was frozen since February 2026 (167 docs). The CI workflow only pinged the live Netlify API (read-only filesystem) so the static file was never actually regenerated by CI. Changes: - scripts/build-search-index.js: replace id:filePath (absolute OS path) with id:url so the index is path-portable across all environments - static/search-index.json: rebuilt locally with the fixed indexer; now contains 208 portable relative-URL ids and a current buildTime - .gitignore: exclude static/search-index.json from accidental manual commits; the CI workflow intentionally force-adds it via git add -f - .github/workflows/rebuild-docs-index.yml: add Node setup + index rebuild + git commit-back steps so the file stays current on every content change; use npm install (not npm ci) because package-lock.json is listed in .gitignore and would not be present in the CI checkout; use fetch-depth:0 and explicit GITHUB_TOKEN for push authentication; validate SITE_URL starts with https:// before passing to curl; demote Netlify reload to non-fatal since static file is source of truth Fixes krkn-chaos#471 Signed-off-by: vipulpandey21 <vipulpandey7917@gmail.com>
d594fc0 to
9256a17
Compare
Problem
Fixes #471
static/search-index.json-- the file the AI chatbot uses to powerdocumentation search -- was committed with absolute filesystem paths from
a specific contributor's machine hardcoded into every document
idfield(
/Users/sahil/website-1/content/en/...across all 167 documents), andfrozen since February 13, 2026.
The chatbot's
DocumentationIndex.jsfetches this file at runtime, sothe AI assistant was searching a 3-month-old, path-polluted index and
returning no results for any doc page added since then.
Root cause:
scripts/build-search-index.jsusedid: filePath(rawabsolute OS path) instead of the already-computed relative URL. The CI
workflow only POSTed to the live Netlify serverless function, which runs
on a read-only filesystem and cannot write back to the static file — so
static/search-index.jsonwas never actually regenerated by CI.Changes
scripts/build-search-index.js(1 line)id: filePath→id: urlurlis already computed two lines above as a portable relative path(e.g.
/docs/scenarios/pod-scenario/). No other logic changes..gitignorestatic/search-index.jsonto prevent contributors fromaccidentally committing a locally-built, machine-specific version.
The CI workflow intentionally force-adds it via
git add -f..github/workflows/rebuild-docs-index.ymlnode scripts/build-search-index.jsto regeneratethe static file from source on every content change.
mainwith[skip ci]to preventworkflow loops.
fetch-depth: 0+ explicitGITHUB_TOKENso the pushauthenticates correctly in the Actions runner.
now the source of truth.
Testing
idfields in the committed index contain/Users/sahil/website-1/...(another contributor's Mac path).buildTime: 2026-02-13— index was 3+ months stale.git log -- static/search-index.jsonshows only 3 commitsever, none triggered by CI automation.
build-search-index.jsis the only change to theindexer logic; all other fields were already correct.
Signed-off-by
Signed-off-by: Vipul Pandey vipulpandey7917@gmail.com