Missing upper bound on events_count causes UInt16 overflow

Đang mở Phù hợp với người mới
#696 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

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

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
82/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
postgresql, typescript
Lĩnh vực
backend, databases

Hướng nghiên cứu

Đọc bộ kiểm tra hợp lệ events_count trong packages/core/src/modules/ingest/ingest.constants.ts, sau đó kiểm tra cách trình xử lý replay truyền giá trị này trong packages/core/src/modules/ingest/ingest.service.ts và xem xét cột ClickHouse trong packages/db/src/code-migrations/10-add-session-replay.ts. Thêm các bài kiểm tra xác thực giới hạn cho 65,535 và 65,536; hoàn thành khi 65,535 được chấp nhận và các giá trị lớn hơn bị từ chối trước khi cơ sở dữ liệu phân tích cú pháp.

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

Mô tả

Description

While going through the session replay ingestion flow, I noticed that events_count doesn't have an upper bound in zReplayPayload, even though the corresponding ClickHouse column is of type UInt16.

Unlike chunk_index, which already has a .max(65_535) check, events_count accepts integers beyond the database's supported range. The replay handler also forwards this value unchanged.

without .max(65_535)

image

with .max(65_535')

image
Steps to reproduce

I reproduced the overflow locally using ClickHouse 26.1.3:

SELECT events_count
FROM format(
    JSONEachRow,
    'events_count UInt16',
    '{"events_count":65536}'
);

Actual result: 0

Expected behaviour: Values exceeding 65,535 should be rejected during request validation rather than silently wrapping around during database parsing.

A control query with 65535 returns the correct value.

Relevant files
  • packages/core/src/modules/ingest/ingest.constants.ts
  • packages/core/src/modules/ingest/ingest.service.ts
  • packages/db/src/code-migrations/10-add-session-replay.ts
Proposed fix

Add .max(65_535) to the events_count validator, consistent with chunk_index, along with boundary validation tests.

Are replay chunks exceeding 65,535 events intentionally supported? If not, I would be happy to submit a PR for this.

Ngôn ngữ chính
TypeScript
Star
7.3k
Fork
552
Merge trung bình
1 ngày 10 giờ
Pull request đã merge (30 ngày)
13

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

  • Có Dockerfile hoặc tệp Docker Compose
  • Không có mẫu pull request
  • Không có hướng dẫn đóng góp

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 Openpanel-dev/openpanel

Tất cả issue của Openpanel-dev/openpanel

Issue tương tự

Thêm issue về TypeScript

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.