Code search: some queries 500 (Forgejo explore.Code panic, index out of range) #113

Stängd
öppnade 2026-07-18 20:06:30 +00:00 av supernaut · 2 kommentarer
Ägare

Found right after enabling zoekt code search (#76, applied to prod 2026-07-18). Instance-wide code search works — real hits for most queries (gitborg ~2000, zoekt, postgres, caddy, REPO_INDEXER, the, def all 200) — but some single-word queries panic with HTTP 500.

Repro

GET https://git.gitborg.se/explore/code?q=ansible   → 500
GET .../explore/code?q=ansible%20playbook           → 200
GET .../explore/code?q=caddy|forgejo|postgres|the   → 200

Cause (Forgejo-side panic, not our config)

[W] router: failed GET /explore/code?q=ansible … panic in 13.8ms @ explore/code.go:25(explore.Code),
    err=runtime error: index out of range [12] with length 12
[E] PANIC: runtime error: index out of range [12] with length 12

An off-by-one in Forgejo's explore.Code handler (v16.0.0) on a specific result-set shape — the "[12] with length 12" hints at a per-repo/per-language array indexed one past its end. Query-specific (not volume: gitborg returns far more and is fine), reliably triggered by q=ansible.

Assessment / actions

  • Not a rollback. The feature is live and works for the vast majority of searches; this is an upstream edge case. forgejo_repo_indexer_enabled=false + apply remains the escape hatch if it proves worse than thought.
  • Check the Forgejo issue tracker for an existing report of explore.Code index-out-of-range; file upstream with this repro if absent.
  • Evaluate whether bleve (the alternative forgejo_repo_indexer_type) avoids it, as a stopgap, vs. waiting for an upstream fix.
  • Add a note to the runbook v16-specifics zoekt bullet that some queries 500 pending the upstream fix.

Surfaced by: #76. Instance: Forgejo 16.0.0.

Found right after enabling zoekt code search (#76, applied to prod 2026-07-18). Instance-wide code search works — real hits for most queries (`gitborg` ~2000, `zoekt`, `postgres`, `caddy`, `REPO_INDEXER`, `the`, `def` all 200) — but **some single-word queries panic with HTTP 500**. ## Repro ``` GET https://git.gitborg.se/explore/code?q=ansible → 500 GET .../explore/code?q=ansible%20playbook → 200 GET .../explore/code?q=caddy|forgejo|postgres|the → 200 ``` ## Cause (Forgejo-side panic, not our config) ``` [W] router: failed GET /explore/code?q=ansible … panic in 13.8ms @ explore/code.go:25(explore.Code), err=runtime error: index out of range [12] with length 12 [E] PANIC: runtime error: index out of range [12] with length 12 ``` An off-by-one in Forgejo's `explore.Code` handler (v16.0.0) on a specific result-set shape — the "[12] with length 12" hints at a per-repo/per-language array indexed one past its end. Query-specific (not volume: `gitborg` returns far more and is fine), reliably triggered by `q=ansible`. ## Assessment / actions - **Not a rollback.** The feature is live and works for the vast majority of searches; this is an upstream edge case. `forgejo_repo_indexer_enabled=false` + apply remains the escape hatch if it proves worse than thought. - [ ] Check the Forgejo issue tracker for an existing report of `explore.Code` index-out-of-range; file upstream with this repro if absent. - [ ] Evaluate whether `bleve` (the alternative `forgejo_repo_indexer_type`) avoids it, as a stopgap, vs. waiting for an upstream fix. - [ ] Add a note to the runbook v16-specifics zoekt bullet that some queries 500 pending the upstream fix. Surfaced by: #76. Instance: Forgejo 16.0.0.
Upphovsperson
Ägare

Triage — this is an upstream Forgejo bug, not our config

The panic is in Forgejo's explore.Code handler (explore/code.go:25, index out of range [12] with length 12) on Forgejo 16.0.0 — an off-by-one in result rendering, query-specific (q=ansible reliably; most queries, including far larger result sets like q=bitborg, are fine). Nothing in our zoekt config triggers or fixes it.

  • Documented as a known issue in the runbook zoekt bullet (this PR): repro, that it's upstream, the forgejo_repo_indexer_enabled=false escape hatch, and the (untested) bleve stopgap.
  • Not a rollback. Code search works for the vast majority of queries; disabling it over one upstream edge case would be a net loss.
  • bleve stopgap — evaluate, don't switch prod blind. The panic is in result rendering, so switching forgejo_repo_indexer_type may or may not avoid it; it also forces a full reindex. Test in a local/preview instance first.
  • File upstream. Recommend filing on the Forgejo tracker with the exact repro (GET /explore/code?q=ansible → 500; q=ansible%20playbook → 200) if not already reported, and tracking the fix. (Left to a maintainer with a Codeberg account — I can draft the report text if useful.)

Keeping #113 open to track the upstream fix.

## Triage — this is an upstream Forgejo bug, not our config The panic is in Forgejo's `explore.Code` handler (`explore/code.go:25`, `index out of range [12] with length 12`) on Forgejo 16.0.0 — an off-by-one in result rendering, query-specific (`q=ansible` reliably; most queries, including far larger result sets like `q=bitborg`, are fine). Nothing in our zoekt config triggers or fixes it. ## Actions taken / recommended - **Documented as a known issue** in the runbook zoekt bullet (this PR): repro, that it's upstream, the `forgejo_repo_indexer_enabled=false` escape hatch, and the (untested) `bleve` stopgap. - **Not a rollback.** Code search works for the vast majority of queries; disabling it over one upstream edge case would be a net loss. - **`bleve` stopgap — evaluate, don't switch prod blind.** The panic is in result *rendering*, so switching `forgejo_repo_indexer_type` may or may not avoid it; it also forces a full reindex. Test in a local/preview instance first. - **File upstream.** Recommend filing on the Forgejo tracker with the exact repro (`GET /explore/code?q=ansible` → 500; `q=ansible%20playbook` → 200) if not already reported, and tracking the fix. (Left to a maintainer with a Codeberg account — I can draft the report text if useful.) Keeping #113 open to track the upstream fix.
Upphovsperson
Ägare

Dormant: zoekt was disabled in #165 (2026-07-20), so /explore/code is unreachable and this explore.Code panic can't trigger. Closing — re-verify the panic is fixed as part of the zoekt re-enable gate (Forgejo PR 8106, tracked around #162).

Dormant: zoekt was disabled in #165 (2026-07-20), so /explore/code is unreachable and this explore.Code panic can't trigger. Closing — re-verify the panic is fixed as part of the zoekt re-enable gate (Forgejo PR 8106, tracked around #162).
Logga in för att delta i denna konversation.
Ingen milstolpe
Inga tilldelade
1 deltagare
Notiser
Förfallodatum
Förfallodatumet är ogiltigt eller utanför gränserna. Använd formatet "åååå-mm-dd".

Inget förfallodatum satt.

Beroenden

Inga beroenden satta

Referens
bitborg/bitborg-infra#113
Ingen beskrivning angiven.