Skip to content

fix(gateway): guard non-array tools in api metrics#1967

Open
kirillk wants to merge 2 commits intomainfrom
fix/gateway-tools-array-guard
Open

fix(gateway): guard non-array tools in api metrics#1967
kirillk wants to merge 2 commits intomainfrom
fix/gateway-tools-array-guard

Conversation

@kirillk
Copy link
Copy Markdown

@kirillk kirillk commented Apr 3, 2026

Summary

  • guard API metrics tool extraction against truthy non-array tools payloads so /api/gateway/chat/completions does not throw before reaching the upstream provider
  • add regression coverage for object-shaped tools payloads while preserving existing array-based extraction behavior
  • keep the fix scoped to observability preprocessing, matching the incident where the crash happened in getToolsAvailable

Validation

  • pnpm lint src/lib/o11y/api-metrics.server.ts src/lib/o11y/api-metrics.server.test.ts
  • pnpm test -- --runInBand src/lib/o11y/api-metrics.server.test.ts

@kilo-code-bot
Copy link
Copy Markdown
Contributor

kilo-code-bot bot commented Apr 3, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files)
  • src/lib/o11y/api-metrics.server.ts
  • src/lib/o11y/api-metrics.server.test.ts

Reviewed by gpt-5.4-20260305 · 152,082 tokens

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant