Skip to content

Use llmgateway mode constants for direct/proxy modes - #5790

Merged
JAORMX merged 1 commit into
mainfrom
cleanup-llmgateway-mode-literals
Jul 14, 2026
Merged

JAORMX merged 1 commit into
mainfrom
cleanup-llmgateway-mode-literals

Conversation

@JAORMX

@JAORMX JAORMX commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

The llmgateway package declares ModeDirect/ModeProxy/ModeCredentialHelper/ModeCodexAuth as the single compiler-checked source of truth for gateway-mode strings. Its own doc comment states they exist so both packages "reference one compiler-checked set of values rather than carrying private string copies that can drift."

ModeCredentialHelper (and, on the Codex branch, ModeCodexAuth) already follow this, but the direct/proxy client registrations and hasProxyMode still hand-typed the raw "direct"/"proxy" literals — the exact drift the constants were introduced to prevent. This was surfaced by a review comment on #5789 (Codex support); the fix there covered the warnTLSSkipVerify switch it touched, and this PR sweeps the rest so main is consistent.

Swapping the literals to the constants makes a typo a compile error instead of a silently-unmatched mode.

  • pkg/client/config.go: 6 LLMGatewayMode: "proxy"/"direct" registrations → llmgateway.ModeProxy/ModeDirect
  • pkg/llm/setup.go: hasProxyMode's t.Mode == "proxy" → llmgateway.ModeProxy

Purely mechanical — no behaviour change.

Type of change

  • Refactor (no functional change)

Test plan

  • Unit tests (task test — pkg/client, pkg/llm)
  • Linting (golangci-lint — 0 issues)
  • Build (task build)

Does this introduce a user-facing change?

No.

Special notes for reviewers

warnTLSSkipVerify's "direct"/"proxy" cases are deliberately not touched here — they're being converted in #5789, which actively modifies that switch. Kept separate to avoid a merge conflict between the two PRs.

Generated with Claude Code

The llmgateway package declares ModeDirect/ModeProxy as the single
compiler-checked source of truth for gateway mode strings, and its doc
comment says they exist "rather than carrying private string copies that
can drift." ModeCredentialHelper already followed that; the direct/proxy
client registrations and hasProxyMode still hand-typed the literals.

Swap the remaining "direct"/"proxy" literals to the constants so a typo
becomes a compile error instead of a silently-unmatched mode. Purely
mechanical — no behaviour change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@JAORMX
JAORMX requested review from amirejaz and lujunsan as code owners July 14, 2026 07:18
@github-actions github-actions Bot added the size/XS Extra small PR: < 100 lines changed label Jul 14, 2026
@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.76%. Comparing base (d2f6812) to head (fb00812).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5790      +/-   ##
==========================================
- Coverage   70.83%   70.76%   -0.07%     
==========================================
  Files         684      684              
  Lines       69355    69355              
==========================================
- Hits        49125    49081      -44     
- Misses      16624    16685      +61     
+ Partials     3606     3589      -17     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@JAORMX

JAORMX commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator Author

Context: this originated from a review comment on #5789 (Codex LLM-gateway support), where the warnTLSSkipVerify switch mixed raw "direct"/"proxy" literals with the llmgateway.ModeCodexAuth constant. That switch is fixed in #5789 itself (commit d564073); this PR handles the rest of the literals so main is consistent. Independent of #5789 — no overlapping lines — so the two can merge in either order.

@JAORMX
JAORMX merged commit 76f76bd into main Jul 14, 2026
47 of 48 checks passed
@JAORMX
JAORMX deleted the cleanup-llmgateway-mode-literals branch July 14, 2026 08:38
@github-actions github-actions Bot mentioned this pull request Jul 14, 2026
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XS Extra small PR: < 100 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants