Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

@CosmosDBInput ignores partitionKey

Đang mở
#134 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
azure, java
Lĩnh vực
backend, cloud

Hướng nghiên cứu

Bắt đầu với annotation @CosmosDBInput trên handleCommand và theo dõi cách giá trị partitionKey của nó được phân giải từ request body. Tái hiện ví dụ với events collection, sau đó xác minh liệu binding có lọc theo streamId được yêu cầu hay không; hoàn tất khi binding chỉ trả về các event khớp hoặc ghi rõ hành vi được hỗ trợ.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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?

Ngôn ngữ chính
Java
Star
46
Fork
49
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Azure/azure-functions-java-library

Tất cả issue của Azure/azure-functions-java-library

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.