Skip to content

Default 'assets' directory exclusion silently swallows API route files (pages/api/assets) #1219

Description

@jscyrus

Summary

Directories named assets are excluded from indexing by default — reasonable for static files, but under Next.js API trees, pages/api/assets/ contains live route handlers (asset proxy endpoints, typically with dynamic [param].ts files taking attacker-controlled input). Those files are silently absent from file_hashes and produce no nodes.

To your credit, the index response DOES announce it ("excluded":{"dirs":["pages/api/assets"]}) — consumers who read that field can compensate (we are wiring that in on our side). The ask is about the default's blast radius, not silence.

Verified repro (2 minutes, CBM 0.9.0)

mkdir -p /tmp/repro/pages/api/assets /tmp/repro/pages/api/things
# a live proxy route where Next.js conventions put it:
echo 'const handler=(req:any,res:any)=>res.end("x"); export default handler;' \
  > "/tmp/repro/pages/api/assets/[assetId].ts"
# controls:
echo 'const handler=(req:any,res:any)=>res.end("x"); export default handler;' > /tmp/repro/pages/api/plain.ts
echo 'const handler=(req:any,res:any)=>res.end("x"); export default handler;' > "/tmp/repro/pages/api/things/[thingId].ts"

codebase-memory-mcp cli index_repository --repo-path /tmp/repro --mode moderate --name repro
# response: "excluded":{"dirs":["pages/api/assets"],"count":1}
sqlite3 ~/.cache/codebase-memory-mcp/repro.db "SELECT rel_path FROM file_hashes WHERE project='repro';"
# observed: pages/api/plain.ts, pages/api/[direct].ts, pages/api/things/[thingId].ts
#           — bracket names walk FINE; the assets/ subtree is the omission

We hit this on a large private TypeScript monorepo, where several live API route files under assets/ directories were silently absent from the graph. Route handlers under assets/ paths are a common Next.js pattern for asset proxying, so the excluded files tend to be exactly the parameterized, input-handling endpoints a code-graph consumer most needs.

Asks

  1. Is the assets exclusion configurable per project? If yes, a pointer to the setting is all we need; if not, please consider one (or an exception when the dir sits under a route tree like pages/api/ / app/api/).
  2. Consider not excluding directories that contain .ts/.js source files — static-asset dirs rarely do.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingparsing/qualityGraph extraction bugs, false positives, missing edgespriority/highNeeds near-term maintainer attention; high-impact bug, regression, safety issue, or release blocker.ux/behaviorDisplay bugs, docs, adoption UX

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions