Skip to content

[Audit-Medium] valid service type shapes are mishandled #4462

@pepone

Description

@pepone

AI-generated audit finding — this issue was opened from an automated security/correctness audit. It has not been triaged by a human yet; verify the reasoning, reproducibility, and severity before acting on it.

Medium: valid service type shapes are mishandled — CONFIRMED

Affected code:

Verification:

Confirmed on three distinct axes:

  1. Records[Service] on public partial record class Foo never triggers the generator because the syntax predicate only matches ClassDeclarationSyntax, not RecordDeclarationSyntax. No diagnostic, no generated file — silent failure.
  2. GenericsclassSymbol.Name is "Foo" for Foo<T>; the emitted partial class Foo { ... } doesn't merge with the user's partial class Foo<T> and the build fails with a type-not-partial error, pointing nowhere useful.
  3. Multi-level nestingclass Outer { class Middle { [Service] class Leaf { } } } emits partial class Middle { partial class Leaf { ... } } without Outer, which the compiler rejects because the generated source declares Middle at the global/namespace scope rather than inside Outer.

Impact:

  • Supported-looking service declarations silently fail to generate (records).
  • Nested and generic services break compilation with malformed generated code.
  • Failure points don't lead the developer back to the root cause.

Recommendation:

  • Expand the syntax predicate to TypeDeclarationSyntax (or specifically ClassDeclarationSyntax or RecordDeclarationSyntax) and widen the cast accordingly.
  • Capture the full type syntax for the service class (class Foo<T> where T : …) and for each enclosing container, including generic parameters and constraints.
  • Iterate on parentNode in a loop so every enclosing type is captured.
  • Add regression tests for record classes, multi-level nesting, and generic service types.

Status: Valid, Medium severity.


Source report: src-IceRpc.ServiceGenerator-audit-2026-04-14.md (finding valid service type shapes are mishandled — **CONFIRMED**)

Severity (auditor-assigned): Medium

Metadata

Metadata

Assignees

No one assigned

    Labels

    ai-auditAI-generated audit finding — needs human triagecode generators

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions