Skip to content

TS/JS extraction: a comment interleaved in a decorator run drops every decorator above it #1095

Description

@JhohanBustamante

Summary

extract_decorators() walks prev-siblings and breaks on the first named
tree-sitter node. Comments are named nodes, so a comment interleaved in a
decorator run ends the walk early and silently drops every decorator above
the comment.

Reproduce

Index a TypeScript file with a comment between decorators:

@Post('login')                                     // dropped
@HttpCode(HttpStatus.OK)                           // dropped
// throttled per IP and per account
@Throttle({ default: { ttl: 900_000, limit: 5 } }) // kept
async login(dto: LoginDto) { ... }

The method ends up with only @Throttle. @Post/@HttpCode are gone, so the
route disappears from any decorator/route/authz query — documenting a decorator
with an explanatory comment removes the endpoint from the graph.

Impact

On a real NestJS backend, exactly 1 of 95 HTTP endpoints was missing from the
graph — the one whose throttle policy carried an explanatory comment.

Expected

Comments should be transparent to the prev-sibling walk, the same way the
anonymous tokens (e.g. the TS export keyword) already are. The existing
is_comment_node() helper can be reused.

Environment

Found while indexing a NestJS + Angular monorepo. Affects any framework whose
decorators/annotations can be interleaved with comments (NestJS, Angular, etc.).

A reproduce-first regression test
(extract_ts_decorators_survive_interleaved_comment) and the fix are ready; PR
to follow, linked to this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingparsing/qualityGraph extraction bugs, false positives, missing edgespriority/highNeeds near-term maintainer attention; high-impact bug, regression, safety issue, or release blocker.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions