已关闭
[issue] duplication_output_bytes 超限时 BM403 human 输出 Cause 误显 "format unsupported" #14
cezarbbb创建于  9月9日关闭于  9月17日
cezarbbb
9月9日 创建
name about title labels
BotMetric 问题单 报告 BotMetric 中可复现的问题 [Issue] duplication_output_bytes 超限时 BM403 human 输出 Cause 误显 format unsupported,误导排查方向 bug, output, low

问题概述

触发 duplication_output_bytes 输出预算超限(实测 4899 字节 > 100 字节预算)时,BM403 的 human 输出 Cause 行与"输出格式非法"(OUTPUT_FORMAT_INVALID)共用文案,显示 format unsupported,与真实原因(输出预算超限)不符;真实原因需查看 stderr 错误首行。首次出现版本:v1.1.0(该预算键为 v1.1.0 新增)。受影响对象:所有输入类型(输出层问题,与输入无关)。实际影响:超限场景错误归因错误,延长排查时间。本问题不涉及指标数值,涉及诊断文案口径。

影响范围

项目 内容
分析对象 ☑ Cargo 软件包 ☑ 工作空间 ☑ 独立 .rs 文件(输出层问题,与输入类型无关)
受影响的指标、规则或报告字段 BM403 诊断的 human 输出 Cause 行(与 OUTPUT_FORMAT_INVALID 共用文案)
影响程度 ☑ 轻微
临时规避办法 ① 以 stderr 错误首行为准判断真实原因;② 结合 BM-OBS-5-2 的规避办法(改用 --output 或调大预算)避免触发该场景

复现步骤

最小源码样例:夹具 fixtures\dup-many(48 个 .rs 文件、831 行)。自包含最小样例如下(与夹具同构的重复文件对,足以触发输出预算超限;下述命令中的 <dup-pair> 即指向该样例目录):

dup-pair/
├── Cargo.toml
└── src/
    ├── lib.rs
    ├── dup_a.rs
    └── dup_b.rs

Cargo.toml:

[package]
name = "dup-pair"
version = "0.1.0"
edition = "2021"

src/lib.rs:

pub mod dup_a;
pub mod dup_b;

src/dup_a.rs:

// dup_a.rs — intentionally duplicated with dup_b.rs (12 identical NBNC lines).

pub fn transform_a(values: Vec<u32>, factor: u32) -> Vec<u32> {
    let mut out = Vec::with_capacity(values.len());
    for v in values {
        if v == 0 {
            continue;
        }
        let scaled = v * factor;
        if scaled > 1000 {
            out.push(1000);
        } else {
            out.push(scaled);
        }
    }
    out
}

pub fn summarize_a(values: &[u32]) -> u32 {
    values.iter().copied().sum()
}

src/dup_b.rs:

// dup_b.rs — intentionally duplicated with dup_a.rs (12 identical NBNC lines).

pub fn transform_b(values: Vec<u32>, factor: u32) -> Vec<u32> {
    let mut out = Vec::with_capacity(values.len());
    for v in values {
        if v == 0 {
            continue;
        }
        let scaled = v * factor;
        if scaled > 1000 {
            out.push(1000);
        } else {
            out.push(scaled);
        }
    }
    out
}

pub fn summarize_b(values: &[u32]) -> u32 {
    values.iter().copied().sum()
}

配置 bot-metric-dup-out.toml(同 BM-OBS-5-2):

[thresholds]
duplication_output_bytes = 100

[rules]
duplication_findings = "all"
  1. BM110 analyze <dup-many> --config bot-metric-dup-out.toml --format human
  2. 查看 human 报告中的 Cause 行
  3. 对照 stderr 错误首行中的真实原因(超限字节数 4899 > 100)
  4. x86 与 ARM64 各执行一次并对比

预期结果

Cause 应指向输出预算超限(如 report output budget exceeded),与"输出格式非法"场景文案区分。

实际结果

human 输出 Cause 显示 format unsupported(与格式非法共用文案);stderr 首行才是真实原因(输出超限 4899 > 100)。两平台行为一致。证据:x86_linux\records\batch-09\verify-groupB_5-2_5-3_5-4.txt;arm_linux\records-arm64\batch-09\verify-groupB_5-2_5-3_5-4.txt。

证据原文(x86_linux\records\batch-09\verify-groupB_5-2_5-3_5-4.txt,5-3 部分):

=== 5-3 复现:BM403 human Cause 文案误导 ===
ERROR error[BM403]: rendered report requires 4971 bytes, exceeding configured duplication output limit 200

  Command     Analyze
--
  Cause       the output format is unsupported for this command
  Next        use `human`, `json`, or `sarif` where supported

证据原文(arm_linux\records-arm64\batch-09\verify-groupB_5-2_5-3_5-4.txt,5-3 部分):

=== 5-3 复现:BM403 human Cause 文案误导 ===
命令:BM110 analyze fixtures/demo-pkg --config fixtures/configs/bot-metric-dup-out.toml --format human
exit=2,stdout 空,BM403 错误输出至 stderr:
ERROR error[BM403]: rendered report requires 4899 bytes, exceeding configured duplication output limit 200

  Command     Analyze
  Stage       complete
  Cause       the output format is unsupported for this command
  Next        use `human`, `json`, or `sarif` where supported

与 x86 归档同构(x86 为 requires 4971 bytes,ARM 批次 5 记录同为 4899;差值源于夹具重建的源文件内容长度差异,非行为差异)。
误导文案复现成立:实际原因(输出超限 4899 > 200)与显示的 Cause("the output format is unsupported for this command")不符。

分析环境与范围

项目 内容
BotMetric 版本或提交号 v1.1.0(commit 8ef52f6)
操作系统与架构 x86_64 Linux(rustc/cargo 1.95.0)+ aarch64 Linux(rustc/cargo 1.98.0),均 root 用户
软件包 / 目标 / 特性 / 范围参数 dup-many(目录输入,默认 scope);--config bot-metric-dup-out.toml --format human
文件数 / 代码行数 48 个 .rs 文件 / 831 行
模块层级 / 重复窗口 11 行连续重复块 22 组 + 完全重复文件对 1 组

指标、发现与报告证据

  • ☑ 已说明发现条目的编号、严重级别、位置和 human_message:BM403 / error / 无位置 / human 输出 Cause = format unsupported(误导性文案,原文见证据文件)
  • ☑ 已附 analysis-report:human 输出与 stderr 全文存于证据文件(verify-groupB)
  • ☐ 指标口径:不适用(诊断文案问题,指标计算正常)
  • ☑ 已说明 Cargo/独立文件口径差异:不适用(与输入类型无关)

性能与资源证据

项目 内容
冷缓存 / 热缓存 热缓存复现(与缓存无关)
执行次数 / 基线 每平台 ≥2 次(原批次 + 批次 9 复现),结果一致
总耗时 x86 约 51ms(dup-many 热缓存量级);ARM64 约 0.05s
处理器占用 / 内存峰值 未采样(本项非性能问题)
采样工具 无
测试数据集规模 / 硬件条件 dup-many 48 文件 831 行;x86_64 与 aarch64 Linux 服务器(root)

附件与提交确认

  • ☑ 已检索现有问题单,确认不是重复问题
  • ☑ 已提供最小复现步骤、预期结果和实际结果
  • ☑ 已明确指标公式、统计范围和实际证据(如适用)——本条为诊断文案问题,不涉及指标
  • ☑ 已完成日志、配置、源码和附件脱敏(输出不含本机用户路径)
likedislike
WWangZijun成员
9月15日 关联了pull request:fix: preserve bounded machine output and ordering (issue#9_14_15)
WangZijun成员
9月15日 评论:

https://gitcode.com/xuanwu/bot-metric/merge_requests/8

结论:

  • 问题可复现:已通过修复前最小复现/回归测试确认。
  • 问题可修复:当前分支集成测试已验证修复行为。

具体修复:

  • 在输出预算检查前完成机器 JSON 序列化,避免 stdout 产生截断 JSON。
  • 区分输出预算超限与格式错误的 BM403 原因。
  • 明确 duplication top 模式的重复行数及 stable_subject 字典序取舍规则并增加测试。
likedislike
VVaynNecol成员
9月17日 关闭了 issue