Skip to content

Fewer code reader errors; real client addresses behind the portal - #27

Merged
qiansc merged 1 commit into
mainfrom
fix/code-reader-probe-and-client-ip
Nov 29, 2026
Merged

qiansc merged 1 commit into
mainfrom
fix/code-reader-probe-and-client-ip

Conversation

@qiansc

@qiansc qiansc commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Background

The query error log on the public site filled with warnings from code-reader page views (mostly a crawler): every directory view read the directory as a file (NOT_A_FILE), and a link to a commit outside retention produced four or five failing requests. All visitors also appeared as the portal's address.

Changes

  • Code reader: list the root first; an unreadable commit is reported once. File or directory is decided from the parent listing, so directories are not read as files. The latest-commit offer checks the path through the parent listing.
  • BINARY_FILE is a caller-side warning.
  • SOURCEGRAPH_TRUSTED_PROXIES: gateways whose X-Forwarded-For names the client; fly.toml trusts fdaa::/16 (the portal reaches the service over Fly's private network and forwards Fly-Client-IP, Pass the Fly client IP to Source Graph portal#58).
  • Docs (docs/interfaces.md).

Compatibility

Without the setting nothing is trusted, as before. Deploy context4ai/portal#58 first.

Testing

go vet, go test ./..., bun run check; a headless browser against a local build: directory views make no failing request (before: one read 422), a stale commit makes one (before: four or five) and still offers the latest commit; a spoofed X-Forwarded-For from an untrusted peer is ignored.

🤖 Generated with Claude Code

- Code reader: the root listing checks the commit first, so an
  unreadable commit is reported once without further requests, and the
  parent listing tells files from directories, so a directory is no
  longer read as a file (NOT_A_FILE). The latest-commit offer checks the
  path through the parent listing instead of a read.
- BINARY_FILE is a caller-side warning, not a service error.
- SOURCEGRAPH_TRUSTED_PROXIES (comma-separated CIDRs) names gateways
  whose X-Forwarded-For identifies the client; fly.toml trusts the Fly
  private network the portal uses, so anonymous limits and the query
  error log see each visitor.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@qiansc
qiansc merged commit 13ad30c into main Nov 29, 2026
3 checks passed
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