Python async interface bridge ignores untyped parameters

Author: n0tl3ssCreated Sep 24, 2026Updated Sep 24, 2026

Expected behavior

An untyped optional Python parameter should not prevent an async def from implementing a Java interface method whose return type is Publisher, Mono, or Flux.

This is the behavior documented in Async/Await: the coroutine should be adapted to the declared reactive return type and start on subscription.

Reproducer

Add a Java interface method:

java
default Mono<String> findWithCallback(String id, Consumer<String> callback) {
    return Mono.just("default");
}

and override it in Python:

python
async def findWithCallback(self, id: str, callback=None) -> str:
    return id

Calling finder.findWithCallback("c", null).block() fails. A focused regression test reproduces this in ReactiveReturnTypeSpec on the 5.2.x branch.

Actual behavior

The generated Java class contains two methods:

  1. The interface-compatible Publisher/Mono method treats the coroutine itself as a Publisher and calls convertPublisher.
  2. A second CompletionStage overload is generated from the Python method.

Subscription then fails with:

UnsupportedOperationException: Unsupported operation identifier 'subscribe' and object '<coroutine object ...>'

Root cause

PythonStubGenerator.resolveDeclaredBridgeMethod does not select the Python method when an untyped parameter resolves to Object but the corresponding Java parameter is more specific, such as Consumer. Async detection therefore sees the Java interface method instead of the Python async def, bypassing the existing coroutine-to-Publisher path.

Parameter names do not affect this. Requiring a java.util.function.Consumer annotation would expose Java implementation details in otherwise idiomatic Python code.

Versions

  • Micronaut Core 5.2.x at b3464ec
  • GraalPy 25.4.4.1.1
  • Also reproduced end-to-end with Pyronaut 0.0.4 and Micronaut Core 5.2.5

Source: micronaut-projects/micronaut-core