Skip to content

_rebuild_code() KeyError: detect() returns dict not FileType-keyed #148

Closed

Description

@harreh3iesh

Bug

graphify.watch._rebuild_code() crashes because it accesses detected[FileType.CODE] but detect() returns detected['files']['code'].

# watch.py line ~17
detected = detect(watch_path, follow_symlinks=follow_symlinks)
code_files = [Path(f) for f in detected[FileType.CODE]]  # KeyError

The error message is confusing because it prints the enum repr:

[graphify watch] Rebuild failed: <FileType.CODE: 'code'>

Fix

code_files = [Path(f) for f in detected['files']['code']]

Context

Found this while wiring graphify into post-commit git hooks. The hook calls _rebuild_code() on every commit and it silently fails. Built a workaround that calls the pipeline directly via detect() → extract() → build_from_json() → etc.

Version: graphifyy 0.3.21

Happy to PR the fix if you'd like.

Activity

  1. safishamsi commented on Apr 9, 2026

    @safishamsi
    Member

    Fixed in v0.3.22. The fix is exactly what you suggested — detected['files']['code'] instead of detected[FileType.CODE]. Also removed the now-unused FileType import from watch.py. Upgrade with pip install --upgrade graphifyy then re-run graphify hook install.

  2. harreh3iesh commented on Apr 9, 2026

    @harreh3iesh
    Author

    This made my day thank you. 🥹

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions