Targeting: a stored ruleset the reader cannot parse raises, failing the bulk flags call and the SDK ruleset for every flag

未关闭
#1,674 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
半天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
python
领域
backend

调研方向

Start in backend/app/core/targeting_adapter.py at normalise_targeting_rules, where the documented never-raises contract is broken for exceptions other than TargetingRulesError. Reproduce with a stored geo_within_radius whose radius is a very large integer (OverflowError) and a semver value like "1.²" (ValueError), then trace how get_user_flags, build_ruleset and segment membership call it. Done when one bad stored ruleset yields error for only its own flag while the bulk call and ruleset document still succeed, with tests covering both exception types.

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

描述

bug post-launch

Problem

normalise_targeting_rules (backend/app/core/targeting_adapter.py) documents that invalid content never raises, but a stored ruleset whose reading raises an exception other than the ones it catches escapes it. Measured at 3a6eb775 (with #1664's branch on top, which touches no targeting code): a stored dashboard geo_within_radius whose radius is a 401-digit integer makes normalise_targeting_rules raise OverflowError. The principal engineer's review of the #1666/#1669/#1672 plan measured the same with a ValueError (a stored dashboard semver value "1.²", which a save refuses).

What a reader then does with one such stored flag, measured in that review:

  • get_user_flags and build_ruleset raise, so the bulk flags call and the SDK ruleset document fail for every flag, not only this one;
  • segment membership raises (it catches only TargetingRulesError);
  • every evaluation of the flag answers error and writes an error-log row, which the safety monitor counts.

No API route can write such a row (saves refuse or, until #1672 is fixed, answer 500 without writing); it takes a direct database write or a row stored before validation existed.

Expected

A stored ruleset that cannot be read affects only its own flag, experiment or segment. The fix is a read-path decision: catching the exception broadly in normalise_targeting_rules makes the flag fall back to its global rollout (fails open, as returning None does today for the cases it catches), so the likely shape is a per-flag catch that answers error for that flag and lets the bulk call and the ruleset document go on. The docstring's promise is made true either way.

主要语言
Python
星标
0
派生
4
平均合并
5 小时 19 分钟
30 天内合并 PR
503

环境准备

从这里开始

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

Controlvar/controlvar 的其他 Issue

查看 Controlvar/controlvar 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

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