Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

@CosmosDBInput ignores partitionKey

Open
#134 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
azure, java
Domain
backend, cloud

Research direction

Start with the @CosmosDBInput annotation on handleCommand and trace how its partitionKey value is resolved from the request body. Reproduce the example with the events collection, then verify whether the binding filters by the requested streamId; done means the binding returns only matching events or clearly documents the supported behavior.

Written by the indexing model from the issue text.

Description

area:java-functions

In my Micronaut Azure Function I am using a binding @CosmosDBInput for event-sourcing like this:

public class ChatRoomFunction extends AzureFunction {

  @FunctionName("handleCommand")
  public HttpResponseMessage handleCommand(
    @HttpTrigger(
      name = "req",
      methods = HttpMethod.POST,
      authLevel = AuthorizationLevel.ANONYMOUS)
    final HttpRequestMessage<Command> request,
    @CosmosDBInput(
      name = "events",
      connectionStringSetting = CONNECTION_STRING,
      databaseName = DATABASE_NAME,
      collectionName = "events",
      partitionKey = "events--{id}") final List<Event> events,
    final ExecutionContext context
  ) {
     // function body intentionally left out
  }
}

// with

public class Command {
  private UUID id;

  // more fields, getters, setters
}

// and

public class Event {
  private String streamId; // this is the CosmosDB partition key

  // more fields, getters, setters
}

Before, I tried doing this using @TableInput which seemed to worked fine.
Now I've switched to CosmosDB and for some reason it seems to ignore my @CosmosDBInput's partitionKey value.

Expected: events should contain a list of only Events having a certain streamId as matched by the binding parameter of the request body, i.e. id.

Actual: events contains a list of ALL Events present in the events collection.

Am I missing something here? This is what the partitionKey is for, right?

Dominant language
Java
Stars
45
Forks
49
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Azure/azure-functions-java-library

All issues in Azure/azure-functions-java-library

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.