Skip to content

fix(callgraph): calls inside asyncHandler-wrapped route handlers missing from graph_edges #231

Description

@Wolfvin

Mengapa

Ditemukan saat spot-check lanjutan pasca fix #219 (module-level call extraction) terhadap KDS backend real. getGoogleClient (src/routes/public/customer-auth.ts:38) menunjukkan rc:0 di search --mode symbol, padahal ada 1 call site nyata di file yang sama (line 86, di dalam route handler customerAuthRouter.post('/auth/google', asyncHandler(async (req, res) => { ... getGoogleClient() ... }))).

Investigasi yang sudah dilakukan (parser TERBUKTI benar, bug ada di layer downstream)

  1. Parser diverifikasi benar — memanggil TSBackendParser.extract_references() langsung terhadap isi file asli (src/routes/public/customer-auth.ts) menghasilkan edge yang benar:

    edges: [{'from': 'src/routes/public/customer-auth.ts:0:<module>', 'to_fn': 'getGoogleClient', 'via_self': False}]

    Reproduksi minimal dengan pattern yang sama (asyncHandler(async (req, res) => { ... }) — arrow function dibungkus function lain sebagai argument, BUKAN argument langsung ke .post()) juga menghasilkan edge yang benar secara isolated.

  2. Edge TIDAK ADA di SQLite — setelah fresh scan (hapus .codelens/ lalu scan ulang), query langsung:

    SELECT source_id, target_id, edge_type FROM graph_edges WHERE target_id LIKE '%getGoogleClient%'
    -- hasil: KOSONG (0 rows)

    Padahal parser (dipanggil langsung, di luar pipeline scan) terbukti menghasilkan edge tersebut. Bug ada di antara parser output dan penulisan ke SQLite — kemungkinan di graph_model.py's populate_graph_tables() (baris ~330-375, tempat proses flat_edges sebelum insert ke graph_edges table).

  3. Pattern yang gagal: router.post(path, asyncHandler(async (req, res) => { ... fn() ... })) — arrow function TIDAK langsung jadi argument ke method routing (.post()), tapi dibungkus SATU LAPIS function call lagi (asyncHandler(...), pattern umum untuk auto-catch async error di Express). Pattern ini dipakai di 18 file di KDS backend (grep -c "asyncHandler(" src/routes/*.ts → 18 file non-zero) — impact luas kalau genuinely bug.

  4. Kontras dengan yang sudah fixedrequirePermission (rc 0→49) dan hasPermission (rc 1→7) di fix fix(callgraph): extract module-top-level calls to fix rc undercount (closes #210) #219 SUDAH benar, tapi pattern mereka adalah call LANGSUNG sebagai argument (router.post(path, requirePermission('admin'), handler)), BUKAN dibungkus function lain. getGoogleClient gagal karena polanya beda: dipanggil di DALAM arrow function yang itu sendiri adalah argument dari asyncHandler(...).

Konteks

Ini kemungkinan bug BERBEDA dari #219 (yang sudah fixed) dan #223 (trace/impact synthetic source_id) — ini soal edge dari parser yang genuinely hilang sebelum sampai SQLite, bukan soal edge yang ada tapi tidak ter-JOIN. Kalau benar generalizable, banyak fungsi yang dipanggil di dalam handler yang dibungkus asyncHandler-style wrapper akan under-report rc — sama seperti masalah asli #210 tapi untuk pattern yang berbeda.

Tujuan

  1. Investigasi kenapa edge yang terbukti dihasilkan parser (src/routes/public/customer-auth.ts:0:<module>getGoogleClient) tidak masuk ke graph_edges table
  2. Fix root cause, apapun itu (kemungkinan di populate_graph_tables() — baca dulu logic lengkapnya, terutama bagian yang resolve target_id dari to_fn, sebelum simpulkan lokasi bug)
  3. Setelah fix, getGoogleClient harus rc >= 1 di KDS backend

Constraint

  • Investigasi mandiri — jangan asumsikan bug ada di titik yang sudah disebutkan tanpa verifikasi ulang, karena reproduction saya terbatas (belum trace end-to-end dari parser sampai SQLite write)
  • Pastikan fix tidak regress hasil fix(callgraph): extract module-top-level calls to fix rc undercount (closes #210) #219 yang sudah benar (requirePermission rc:49, hasPermission rc:7 di KDS harus tetap sama atau lebih akurat, bukan turun)

Definition of Done

  1. search "getGoogleClient" <kds-path> --mode symbol menunjukkan rc >= 1
  2. Root cause didokumentasikan jelas — kenapa edge dari parser tidak sampai SQLite
  3. Regression check: requirePermission dan hasPermission rc di KDS tetap benar (tidak turun dari 49/7)
  4. Test suite 0 regresi baru

Checklist Laporan Worker

  • Root cause detail: di mana tepatnya edge hilang antara parser output dan SQLite write
  • rc getGoogleClient sebelum/sesudah fix
  • Konfirmasi requirePermission/hasPermission rc tidak regresi
  • Hasil test suite lengkap

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions