Skip to content

fix(openrouter): pin telemetry provider casing against display name - #1439

Open
easonLiangWorldedtech wants to merge 1 commit into
Zoo-Code-Org:mainfrom
easonLiangWorldedtech:fix/issue-1302-openrouter-telemetry-casing
Open

fix(openrouter): pin telemetry provider casing against display name#1439
easonLiangWorldedtech wants to merge 1 commit into
Zoo-Code-Org:mainfrom
easonLiangWorldedtech:fix/issue-1302-openrouter-telemetry-casing

Conversation

@easonLiangWorldedtech

Copy link
Copy Markdown
Contributor

Related GitHub Issue

Closes: #1302

Description

PR #1165 canonicalized the OpenRouter ApiProviderError provider argument to providerIdentifiers.openrouter (lowercase "openrouter"), while the same catch blocks kept passing the display label this.providerName ("OpenRouter") to handleOpenAIError. One error event therefore carried two spellings: lowercase in telemetry, capitalized in the user-facing message.

This PR takes the issue's "keep the stable identifier, document the display name" path:

  • src/api/providers/openrouter.ts — documents the providerName field as the user-facing display name only; telemetry keeps the canonical providerIdentifiers.openrouter value that refactor(providers): canonicalize model-router calls #1165 already shipped (preserving the post-refactor(providers): canonicalize model-router calls #1165 series; the dashboard OR clause is noted in the issue as a maintainer follow-up).
  • src/api/providers/__tests__/openrouter.spec.ts — adds a regression test that pins both sinks with literals (the existing assertions use providerIdentifiers.openrouter on both sides, so they cannot catch a drift): the serialized telemetry event (via extractApiProviderErrorProperties) must carry "openrouter", and the thrown user-facing message must still start with the "OpenRouter" display label. The test avoids as any with a structural cast, so src/eslint-suppressions.json counts are unchanged.

Test Procedure

  • pnpm --filter zoo-code test api/providers/__tests__/openrouter.spec.ts → 25/25 pass (including the new pins provider casing at the telemetry/user boundary (#1302) test).
  • pnpm --dir src exec tsc --noEmit → clean.
  • pnpm --dir src exec eslint --max-warnings=0 api/providers/openrouter.ts api/providers/__tests__/openrouter.spec.ts → clean; suppression counts unchanged (verified via JSON diff of src/eslint-suppressions.json).

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Visual Snapshot (UI changes only): N/A — no user-visible UI change.
  • Documentation Impact: No user-facing documentation changes required (the dashboard OR clause mentioned in the issue is a maintainer-side telemetry follow-up).
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Visual Snapshots

N/A — telemetry-internal change with no rendered UI surface.

Videos (interaction / animation only)

N/A.

Documentation Updates

  • No documentation updates are required.

Additional Notes

Per the issue, either unifying on the display name or keeping the lowercase identifier was acceptable. Keeping the identifier matches #1165's already-shipped telemetry value and the maintainer comment's suggestion of a stable machine provider id; the display label is preserved where users actually read it.

Get in Touch

easonLiangWorldedtech

…oo-Code-Org#1302)

PR Zoo-Code-Org#1165 canonicalized the ApiProviderError provider to providerIdentifiers.openrouter (openrouter) while handleOpenAIError kept the display label this.providerName (OpenRouter), so one error event carried two spellings. Document the providerName field as display-only and add a regression test that pins the serialized telemetry value to the literal lowercase identifier and the user-facing message to the display label, so future drift on either sink fails locally.
@coderabbitai

coderabbitai Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: d8ff444d-bd2b-4346-8963-fe266034f81b

📥 Commits

Reviewing files that changed from the base of the PR and between b55ff87 and cb3c12b.

📒 Files selected for processing (2)
  • src/api/providers/__tests__/openrouter.spec.ts
  • src/api/providers/openrouter.ts

Included review availability: Your plan provides up to 4 included reviews per hour; 1 remains after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout. (5)
  • GitHub Check: platform-unit-test (windows-latest)
  • GitHub Check: compile
  • GitHub Check: platform-unit-test (ubuntu-latest)
  • GitHub Check: e2e-mock
  • GitHub Check: Analyze (javascript-typescript)
🧰 Additional context used
📓 Path-based instructions (8)
Treat model, provider, MCP, path, command, and tool data as untrusted. Check approval and allowlist bypasses, injection and traversal risks, secrets/PII exposure in logs, abort and stream behavior, retries, provider compatibility, and enfor...

⚙️ CodeRabbit configuration file

Files:

  • src/api/providers/openrouter.ts
  • src/api/providers/__tests__/openrouter.spec.ts
Require regression coverage at the lowest valid harness with behavior-focused assertions, including relevant negative, error, false/unset, and boundary cases. Check cleanup and deterministic async behavior and prefer shared typed test helpe...

⚙️ CodeRabbit configuration file

Files:

  • src/api/providers/__tests__/openrouter.spec.ts
Check strict typing and exhaustive behavior across normal, boundary, error, cancellation, retry, and compatibility paths. Verify promises and errors are handled, existing helpers are reused, and new code introduces no `any`, unjustified dou...

⚙️ CodeRabbit configuration file

Files:

  • src/api/providers/openrouter.ts
  • src/api/providers/__tests__/openrouter.spec.ts
Verify extension/webview contracts, cancellation and error propagation, VS Code lifecycle correctness, and behavior under retries and partial failure. Check listeners, resources, and providers are disposed without stale state or duplicate w...

⚙️ CodeRabbit configuration file

Files:

  • src/api/providers/openrouter.ts
  • src/api/providers/__tests__/openrouter.spec.ts
Act as an adversarial second-opinion reviewer. Verify PR claims against implementation, contracts, and tests. Trace changed inputs through normal, boundary, error, cancellation, retry, and default paths and their consumers. Seek plausible c...

⚙️ CodeRabbit configuration file

Files:

  • src/api/providers/openrouter.ts
  • src/api/providers/__tests__/openrouter.spec.ts
Add focused tests for UI binding and save behavior, persistence or normalization, and the value returned by `getStateToPostToWebview()`, including true and false/unset cases when defaults could hide omissions.

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • src/api/providers/__tests__/openrouter.spec.ts
Fix lint violations in new TypeScript code instead of suppressing them.

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • src/api/providers/openrouter.ts
  • src/api/providers/__tests__/openrouter.spec.ts
After editing a file, run ESLint with pruning and zero warnings for that relative file, and confirm its suppression count did not increase.

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • src/api/providers/openrouter.ts
  • src/api/providers/__tests__/openrouter.spec.ts
🔇 Additional comments (2)
src/api/providers/openrouter.ts (1)

147-148: LGTM!

src/api/providers/__tests__/openrouter.spec.ts (1)

20-20: LGTM!

Also applies to: 387-409


📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • Improved consistency between user-facing OpenRouter error messages and the provider identifier recorded in telemetry.
    • Preserved the readable provider label for users while ensuring telemetry uses the canonical provider name.
  • Tests

    • Added coverage to verify provider naming remains consistent across displayed errors and serialized telemetry.

Walkthrough

The OpenRouter provider documents the distinction between its display name and telemetry identifier. A new test verifies that user-facing errors retain "OpenRouter" while telemetry extracts the canonical lowercase "openrouter" value.

Changes

OpenRouter telemetry casing

Layer / File(s) Summary
Provider casing contract and test
src/api/providers/openrouter.ts, src/api/providers/__tests__/openrouter.spec.ts
The provider documents display-name usage. The test validates the user-facing error label and the canonical telemetry provider value.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to cb3c1

This PR documents the existing distinction between the OpenRouter display label and telemetry identifier and adds regression coverage without changing runtime behavior. No actionable merge-blocking risk remains after normal checks and review.

Suggested reviewers: edelauna

🚥 Pre-merge checks | ✅ 6 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR adds the required casing documentation and independent literal-based regression test. However, issue #1302 requires either preserving the historical telemetry value or making both telemetry and… Either change the four handleOpenAIError calls to use providerIdentifiers.openrouter, or restore the telemetry provider values to this.providerName. Update the regression test to verify the selected consistent behavior.
✅ Passed checks (6 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the OpenRouter telemetry casing fix and matches the primary change.
Description check ✅ Passed The description includes the linked issue, implementation details, test procedure, checklist, and documentation impact. It is complete and relevant.
Out of Scope Changes check ✅ Passed The changes are limited to OpenRouter provider documentation and regression coverage for the linked casing issue. No unrelated code changes are identified.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Regression Evidence ✅ Passed PASS. The pull request changes no runtime behavior in openrouter.ts; it adds only a comment. The focused provider test exercises OpenRouterHandler.createMessage, verifies the literal user-facing `…
Trust And Persistence Invariants ✅ Passed PASS. The pull request changes only a production comment and test code. The production diff does not add input handling, persistence, approval logic, resource ownership, or secret/PII processing. The …
Full details: Linked Issues check

Explanation

The PR adds the required casing documentation and independent literal-based regression test. However, issue #1302 requires either preserving the historical telemetry value or making both telemetry and user-facing values use the lowercase identifier. This PR keeps telemetry as "openrouter" while user-facing errors remain "OpenRouter", so the inconsistency remains.

Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2 files.

Full details: Regression Evidence

Explanation

PASS. The pull request changes no runtime behavior in openrouter.ts; it adds only a comment. The focused provider test exercises OpenRouterHandler.createMessage, verifies the literal user-facing "OpenRouter" message, captures the actual ApiProviderError, and verifies extracted telemetry uses literal "openrouter" rather than "OpenRouter". Existing tests cover the other OpenRouter error paths, and no visible UI or snapshot surface changed.

Full details: Trust And Persistence Invariants

Explanation

PASS. The pull request changes only a production comment and test code. The production diff does not add input handling, persistence, approval logic, resource ownership, or secret/PII processing. The existing error path still constructs ApiProviderError with providerIdentifiers.openrouter and passes this.providerName only to handleOpenAIError. The new test uses static strings and a mock OpenAI method; it does not create a changed runtime path that meets any failure condition.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Some tools did not complete. Review the errors below.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/api/providers/__tests__/openrouter.spec.ts

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.

src/api/providers/openrouter.ts

ESLint skipped: the matched ESLint configuration already failed (missing-dependency).


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Aug 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@github-actions github-actions Bot added the awaiting-review PR changes are ready and waiting for maintainer re-review label Aug 29, 2026
@github-actions

github-actions Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Review process

Thanks for contributing. This comment tracks the review sequence and the next action.

  1. Required CI checks pass.
  2. The workflow starts CodeRabbit automatically.
  3. For eligible human-authored PRs, CodeRabbit reviews and approves the latest commit.
  4. A human maintainer reviews and approves after CodeRabbit.

Current step: Ready for human maintainer review and approval.

@github-actions github-actions Bot added awaiting-maintainer CodeRabbit approved; waiting for a human maintainer awaiting-review PR changes are ready and waiting for maintainer re-review and removed awaiting-review PR changes are ready and waiting for maintainer re-review labels Aug 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-maintainer CodeRabbit approved; waiting for a human maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenRouter error telemetry emits inconsistent provider value ("OpenRouter" vs "openrouter")

2 participants