Repository navigation
Description
Problem
When graphifying a FastAPI-heavy Python package, HTTPException becomes a high-degree cross-community bridge / god node even though it is an external framework exception constructor, not a project architecture abstraction.
Observed on graphifyy==0.9.50 while graphifying packages/bsquant_server in a Python monorepo:
- Graph size: 3,634 nodes / 10,820 graph edges / 143 communities.
- Node:
httpexception- label:
HTTPException - source_file: empty string
- origin:
ast - degree: 124
- relations:
calls: 124 - confidence:
EXTRACTED: 9,INFERRED: 115
- label:
- The node appeared as a top bridge / god-node-like result, crossing router communities such as Catalog Router, Workflows Router, Datasets Router, Factors Router, Components Router, and Shared API.
The affected source patterns are ordinary FastAPI error responses, e.g.:
from fastapi import Cookie, Header, HTTPException
raise HTTPException(status_code=401, detail="missing credentials")
raise HTTPException(status_code=403, detail="permission denied")and router exception translation such as:
except CatalogAuthorizationError as exc:
raise HTTPException(status_code=403, detail=str(exc)) from excThese edges make HTTPException look like a core cross-module dependency, but it is really framework error-response construction noise.
Why it seems to happen
From a quick read of the installed extractor:
- The cross-file call resolver walks
all_raw_callsand skips known language builtins, member calls, bash calls, etc. - It then resolves by global label candidate.
- For sourceless external nodes,
_lang_family(nid_to_source_file.get(candidate))isNone, so the cross-language guard keeps the candidate. - If there is a unique candidate but no import evidence, the resolver still emits
callswithconfidence="INFERRED"andconfidence_score=0.85.
Relevant installed-package locations in graphifyy==0.9.50:
graphify/extract.py: cross-file raw-call loop around thecallee in _LANGUAGE_BUILTIN_GLOBALSguard and candidate filtering.graphify/extract.py: direct call emission path that emitscalls/INFERRED/0.85whenhas_import_evidenceis false.
Expected behavior
External framework constructors / exceptions such as FastAPI HTTPException should not become central architecture bridge nodes by default.
Possible fixes:
- Suppress cross-file direct
callsedges to sourceless external call targets unless the target is a project-defined callable or has explicit import evidence tied to a local module. - Namespace sourceless external targets as external dependencies and exclude/downweight them from god node, bridge, and surprising-connection analysis.
- Add common external/framework exception constructors to a noise set, e.g.
HTTPException, while keeping project-defined exception classes intact. - Model this as
raises/error_responsemetadata rather than a project-internalcallsedge.
Reproduction sketch
A minimal FastAPI module likely reproduces it:
from fastapi import APIRouter, HTTPException
router = APIRouter()
@router.get("/x")
def get_x():
raise HTTPException(status_code=404, detail="not found")Run:
graphify .Then inspect graphify-out/graph.json for the httpexception node and its incoming calls edges.
Acceptance criteria
HTTPExceptionand similar sourceless external framework constructors no longer appear as high-degree project bridge / god nodes.- Calls to project-local exception classes still remain represented where useful.
- If external calls are retained, they are typed or downweighted so report sections do not present them as core architecture abstractions.
- Add a regression test for a small FastAPI file that raises
HTTPException(...)from multiple handlers.
Activity
cyber1830 commentedon Aug 29, 2026
I was able to reproduce this on graphify version0.9.50.
A sourceless httpexception node is created. The type-annotation example creates an extracted call, while the bare raise, catch/re-raise, and except HTTPException examples create INFERRED calls to the same node. so the original single-file example didn’t reproduce it, but these combined cases do.
d_type_annotation_make_error -> httpexception | calls | EXTRACTED
a_bare_raise_get_catalog -> httpexception | calls | INFERRED
b_except_reraise_get_workflows -> httpexception | calls | INFERRED
c_except_httpexception_get_datasets -> httpexception | calls | INFERRED
safishamsi commentedon Sep 15, 2026
Fixed in v0.9.62 (on PyPI) via #3531, thanks @DevChiniwala. Thanks for the report!
fix(build): mint typed external stubs for undeclared import endpoints (…
fix(extract): keep constructor calls that hit a same-file annotation …
docs: correct two stale resolver comments