Skip to content

Commit 9846f9e

Browse files
tob-scott-aclaude
andcommitted
fix(thrift): preserve dotted namespace in module IDs
Thrift namespace parts were joined with an empty string, mangling `example.auth` into `exampleauth` in node IDs and breaking cross-file referencing by package. Join with `.` to match the Proto parser's behavior. Regenerate the thrift KAT snapshot and update the entrypoint test expectation accordingly. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 13008fa commit 9846f9e

3 files changed

Lines changed: 24 additions & 24 deletions

File tree

src/trailmark/parsers/thrift/parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def _namespace_id(root: Node) -> str:
7272
for part in named_children(child)
7373
if part.type == "namespace"
7474
]
75-
return "".join(parts)
75+
return ".".join(parts)
7676
return ""
7777

7878

tests/fixtures/kat/thrift/taxonomy.expected.json

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,51 +3,51 @@
33
{
44
"confidence": "certain",
55
"kind": "imports",
6-
"source": "exampleauth",
6+
"source": "example.auth",
77
"target": "common.thrift"
88
},
99
{
1010
"confidence": "certain",
1111
"kind": "contains",
12-
"source": "exampleauth",
13-
"target": "exampleauth:LoginRequest"
12+
"source": "example.auth",
13+
"target": "example.auth:LoginRequest"
1414
},
1515
{
1616
"confidence": "certain",
1717
"kind": "contains",
18-
"source": "exampleauth:LoginRequest",
19-
"target": "exampleauth:LoginRequest.token"
18+
"source": "example.auth:LoginRequest",
19+
"target": "example.auth:LoginRequest.token"
2020
},
2121
{
2222
"confidence": "certain",
2323
"kind": "contains",
24-
"source": "exampleauth",
25-
"target": "exampleauth:AuthService"
24+
"source": "example.auth",
25+
"target": "example.auth:AuthService"
2626
},
2727
{
2828
"confidence": "certain",
2929
"kind": "contains",
30-
"source": "exampleauth:AuthService",
31-
"target": "exampleauth:AuthService.login"
30+
"source": "example.auth:AuthService",
31+
"target": "example.auth:AuthService.login"
3232
},
3333
{
3434
"attributes": {
3535
"type_name": "LoginRequest"
3636
},
3737
"confidence": "certain",
3838
"kind": "type_uses",
39-
"source": "exampleauth:AuthService.login",
40-
"target": "exampleauth:LoginRequest"
39+
"source": "example.auth:AuthService.login",
40+
"target": "example.auth:LoginRequest"
4141
}
4242
],
4343
"language": "thrift",
4444
"nodes": {
45-
"exampleauth": {
45+
"example.auth": {
4646
"branches": [],
4747
"cyclomatic_complexity": null,
4848
"docstring": null,
4949
"exception_types": [],
50-
"id": "exampleauth",
50+
"id": "example.auth",
5151
"kind": "module",
5252
"location": {
5353
"end_col": 0,
@@ -56,16 +56,16 @@
5656
"start_col": 0,
5757
"start_line": 1
5858
},
59-
"name": "exampleauth",
59+
"name": "example.auth",
6060
"parameters": [],
6161
"return_type": null
6262
},
63-
"exampleauth:AuthService": {
63+
"example.auth:AuthService": {
6464
"branches": [],
6565
"cyclomatic_complexity": null,
6666
"docstring": null,
6767
"exception_types": [],
68-
"id": "exampleauth:AuthService",
68+
"id": "example.auth:AuthService",
6969
"kind": "interface",
7070
"location": {
7171
"end_col": 1,
@@ -78,15 +78,15 @@
7878
"parameters": [],
7979
"return_type": null
8080
},
81-
"exampleauth:AuthService.login": {
81+
"example.auth:AuthService.login": {
8282
"attributes": {
8383
"schema_role": "service_function"
8484
},
8585
"branches": [],
8686
"cyclomatic_complexity": null,
8787
"docstring": null,
8888
"exception_types": [],
89-
"id": "exampleauth:AuthService.login",
89+
"id": "example.auth:AuthService.login",
9090
"kind": "method",
9191
"location": {
9292
"end_col": 33,
@@ -113,12 +113,12 @@
113113
"name": "bool"
114114
}
115115
},
116-
"exampleauth:LoginRequest": {
116+
"example.auth:LoginRequest": {
117117
"branches": [],
118118
"cyclomatic_complexity": null,
119119
"docstring": null,
120120
"exception_types": [],
121-
"id": "exampleauth:LoginRequest",
121+
"id": "example.auth:LoginRequest",
122122
"kind": "struct",
123123
"location": {
124124
"end_col": 1,
@@ -131,15 +131,15 @@
131131
"parameters": [],
132132
"return_type": null
133133
},
134-
"exampleauth:LoginRequest.token": {
134+
"example.auth:LoginRequest.token": {
135135
"attributes": {
136136
"schema_role": "field"
137137
},
138138
"branches": [],
139139
"cyclomatic_complexity": null,
140140
"docstring": null,
141141
"exception_types": [],
142-
"id": "exampleauth:LoginRequest.token",
142+
"id": "example.auth:LoginRequest.token",
143143
"kind": "method",
144144
"location": {
145145
"end_col": 17,

tests/test_entrypoints.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def test_schema_entrypoints_detect_operations_only(self, tmp_path: Path) -> None
143143
"example.auth:Auth.Login",
144144
}
145145
assert {ep["node_id"] for ep in thrift.attack_surface()} == {
146-
"exampleauth:Auth.login",
146+
"example.auth:Auth.login",
147147
}
148148
assert {ep["node_id"] for ep in graphql.attack_surface()} == {
149149
"schema:Query.user",

0 commit comments

Comments
 (0)