Add Route nodes and HANDLES edges for DRF ViewSet actions#647
Add Route nodes and HANDLES edges for DRF ViewSet actions#647muskiteer wants to merge 2 commits into
Conversation
Signed-off-by: muskiteer <agarwal.vansh3110@gmail.com>
|
Hi @DeusData, While testing locally, I ran into some issues with the test and lint targets. From what I could tell, these didn't appear to be directly related to the changes in this PR, but please let me know if I missed something. I'd really appreciate any feedback or suggested changes. Happy to update the PR if needed. Thanks |
Signed-off-by: muskiteer <agarwal.vansh3110@gmail.com>
|
Huge thanks for opening this PR and for the work you put into it. The maintainer shop is currently full, so this may sit for a bit before it gets a proper review. We will come back to this as soon as possible with real feedback; I wanted to make sure it did not sit unacknowledged in the meantime. |
|
@DeusData Thanks for the msg. |
|
Thank you @muskiteer — the DRF ViewSet I'm landing it as a focused distillation in #746 (
So the distilled PR keeps your extractor, drops the direction flip, preserves the documented Really appreciate the contribution — the DRF support ships in the next release. 🙏 |
…thods Django REST Framework ViewSets expose extra endpoints through @action-decorated methods, e.g. @action(detail=True, methods=["post"], url_path="approve"). On main these methods carried no route_path, so Phase 2a created no Route node and no HANDLES edge for them -- the endpoint was invisible in the graph (DeusData#603). Add try_drf_action_decorator (internal/cbm/extract_defs.c): when a method's decorator identifier is "action", read the methods / url_path / detail kwargs and set *out_path/*out_method. The existing decorator-route pipeline (ensure_one_decorator_route, Phase 2a) then creates the Route + handler->Route HANDLES edge in the established direction. Fallbacks: method name for url_path, "GET" for methods; detail=True -> /{pk}/<seg>, else /<seg>. Reproduce-first guard: handles_drf_action_python in the edge_types_probe suite -- a DRF @action method must produce >=1 HANDLES edge (RED with 0 edges before the extractor, GREEN after). Known limitation: multi-method actions (methods=["get","post"]) capture only the first method -> a single Route. Distilled from DeusData#647 (thanks @muskiteer). Drops that PR's unrelated project-wide HANDLES edge-direction reversal, which was unnecessary for the fix and broke the handler->Route convention relied on by pass_cross_repo.c's find_route_handler. Closes DeusData#603 Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com> Co-Authored-By: muskiteer <agarwal.vansh3110@gmail.com>
What does this PR do?
This PR adds support for indexing Django REST Framework
ViewSetactions decorated with@actionby emittingRoutenodes andRoute-[:HANDLES]->Methodrelationships.Previously, DRF action methods were indexed only as
Methodnodes, which meant endpoint inventory and endpoint-to-handler mapping were incomplete for projects using DRF routers.Changes
Routenodes for DRF@actionmethods.Route-[:HANDLES]->Methodrelationships linking routes to their corresponding handler methods.Methodextraction.Verification
Reproduced using a minimal Django REST Framework project:
Before:
Methodnode was present.Routenodes were emitted.Route-[:HANDLES]->Methodrelationships existed.After:
Routenode is emitted.Route-[:HANDLES]->Methodrelationship is created.Checklist
git commit -s) — required, CI rejects unsigned commits (DCO, see CONTRIBUTING.md)make -f Makefile.cbm test)make -f Makefile.cbm lint-ci)Fixes #603