Missing upper bound on events_count causes UInt16 overflow

未关闭 适合新手
#696 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
82/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
postgresql, typescript
领域
backend, databases

调研方向

阅读 packages/core/src/modules/ingest/ingest.constants.ts 中的 events_count 验证器,然后检查 replay 处理程序如何在 packages/core/src/modules/ingest/ingest.service.ts 中传递它,并查看 packages/db/src/code-migrations/10-add-session-replay.ts 中的 ClickHouse 列。为 65,535 和 65,536 添加边界验证测试;完成标准是 65,535 被接受,超过该值的数值在数据库解析之前被拒绝。

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
TypeScript
星标
7.3k
派生
552
平均合并
1 天 10 小时
30 天内合并 PR
13

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Openpanel-dev/openpanel 的其他 Issue

查看 Openpanel-dev/openpanel 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。