Skip to content

decorators/query_graph drops one attribute when a method has multiple separate C# attribute brackets (e.g. [HttpPost] + [Route(...)]) #1865

Description

@quockidang

Summary

When a C# method carries two separate attribute brackets on the same declaration — e.g. an HTTP-verb attribute and a [Route(...)] attribute as distinct [...] groups rather than combined in one bracket — the decorators property returned via query_graph for that Method node only contains one of the two attributes. The other is silently dropped.

[HttpPost]
[Route("orders/{id}/confirm")]
public async Task Confirm(Guid id)
{
    ...
}

We queried this via:

MATCH (m:Method)
WHERE m.decorators IS NOT NULL
RETURN m.name, m.file_path, m.decorators

For methods shaped like the example above, m.decorators came back with only the [HttpPost] entry — [Route("orders/{id}/confirm")] was missing — even though the source file on disk clearly has both attributes present. We confirmed this by diffing CBM's output against the raw source for the same file/method.

Impact

We index several ASP.NET Core / ABP-style .NET monoliths where this two-bracket style (verb attribute + route attribute as separate lines) is the dominant convention. Because of this, CBM's built-in :Route node ends up populated for only a small fraction of the routes we'd expect across our indexed repos (on the order of a handful out of tens of thousands of methods with HTTP attributes). We ended up writing a separate regex-based fallback to reconstruct API routes (merging class-level [Route] with method-level [HttpGet]/[HttpPost]) rather than relying on CBM's own decorator/route extraction, since the built-in extraction wasn't usable for this.

Version

Pinned to v0.8.1. We're stuck on this version for an unrelated reason (a separate regression where query_graph's output changed to a human-readable text table with no JSON path in later releases we tried), so we haven't been able to confirm whether this specific decorator-dropping issue still reproduces on main / the latest release. Flagging it here in case it's still present.

Expected behavior

m.decorators (or whatever the AST layer collects for a method's attributes) should include all attribute brackets attached to a method declaration, not just the first/last one found.

Activity

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

    cypherCypher query language parser/executor bugsparsing/qualityGraph extraction bugs, false positives, missing edges

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions