Skip to content

fix(otel,metrics): reject bare string classification_values, whitespace-padded entries, and reserved '_other' bucket (#113) - #118

Merged
rajnisht7 merged 2 commits into
agentrust-io:mainfrom
drk-ram:drk-ram-fix-otel-metrics-113
Nov 25, 2026
Merged

rajnisht7 merged 2 commits into
agentrust-io:mainfrom
drk-ram:drk-ram-fix-otel-metrics-113

Conversation

@drk-ram

@drk-ram drk-ram commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Closes #113

Summary

  • Reject bare str/bytes for classification_values / classificationValues in OTelMetricEmitter (src/agentrust_telemetry/otel.py and packages/typescript/src/metrics.ts) so a string is not iterated character-by-character.
  • Require non-empty, trimmed string entries of at most 128 characters and forbid the reserved fallback bucket "_other" in both Python and TypeScript.
  • Add Python and TypeScript unit tests in tests/test_otel_projectors.py and packages/typescript/test/metrics.test.ts.

Validation

  • pytest tests/test_otel_projectors.py -k "not real and not action_metrics" -q — passed (3 passed, 5 subtests passed)

@drk-ram
drk-ram requested review from a team and imran-siddique as code owners October 25, 2026 06:48
@github-actions

github-actions Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

🟡 Contributor Check: MEDIUM

Check Result
Profile MEDIUM
Credential LOW
Overall MEDIUM

Automated check by AgenTrust Contributor Check.

@github-actions github-actions Bot added the needs-review:MEDIUM Contributor check flagged MEDIUM risk label Oct 25, 2026
@drk-ram
drk-ram force-pushed the drk-ram-fix-otel-metrics-113 branch from 2ce7616 to c3a7ecf Compare October 29, 2026 17:14
…ce-padded entries, and reserved '_other' bucket (agentrust-io#113)

Signed-off-by: Raghuvar Karthik Durga <177662415+drk-ram@users.noreply.github.com>
@drk-ram
drk-ram force-pushed the drk-ram-fix-otel-metrics-113 branch from c3a7ecf to 70f4c9d Compare November 13, 2026 01:13

@dinakarjs dinakarjs left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the Python and TypeScript metric emitters. Both reject bare strings, padded values and the reserved fallback bucket before creating instruments. The full Python suite passed with 167 tests and 179 subtests. The TypeScript build and all 51 TypeScript tests passed using Node's test runner with the tsx import. Hosted workflows await maintainer authorization.

Prepared with OpenAI Codex.

@imran-siddique imran-siddique left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving at 70f4c9d: ran conformance, the Python suite and the TS check on this head; each new test fails against main's source; all 11 PRs in this series merge onto main together without conflicts and pass combined.

@rajnisht7 rajnisht7 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The core fix looks good, a few things needs hardening(can be followed up):

  • Length counting-Python len() counts Unicode code points; JS .length counts UTF-16 code units.Example: 65–128 emoji characters are accepted by Python but rejected by TypeScript.Prefer Array.from(value).length (or equivalent) in TS if the intent is code-point counting.
  • str.strip() and String.trim() disagree on some characters (e.g. U+001C, U+0085, U+FEFF). The same value can be accepted by one SDK and rejected by the other.
    Also missing a few explicit boundary tests (64 entries accept, 128-char accept, 129-char reject, empty string, whitespace-only).

@rajnisht7
rajnisht7 enabled auto-merge (squash) November 25, 2026 07:05
@rajnisht7
rajnisht7 merged commit 93c14fc into agentrust-io:main Nov 25, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-review:MEDIUM Contributor check flagged MEDIUM risk

Projects

None yet

Development

Successfully merging this pull request may close these issues.

otel / metrics: OTelMetricEmitter accepts bare string classification_values (splitting into characters) and reserved '_other' bucket

4 participants