open-code-review/internal/llm
Sunil 027243b734
fix: ensureMessagesSuffix double-paths URLs ending with /v1 (#533)
* fix: ensureMessagesSuffix double-paths URLs ending with /v1

The old check uses strings.Contains(u, '/v1/') which misses URLs
that end with /v1 (no trailing slash after trim). This causes
https://api.anthropic.com/v1/ to become /v1/v1/messages.

Also, Contains matches /v1/ anywhere in the URL including in
hostnames or unrelated path segments, causing false positives.

Fix: use HasSuffix to check for /v1/messages and /v1 endings.

* test: add comprehensive tests for ensureMessagesSuffix

* fix: revert unrelated encoding corruption in resolver_test.go

The previous commit introduced UTF-8 mojibake (em-dash U+2014 replaced
with Latin-1 bytes) in unrelated test comments. This commit restores
the upstream file content verbatim and keeps only the new
TestEnsureMessagesSuffix test function.

* fix: revert unrelated encoding corruption in resolver.go

Restore upstream file encoding, keeping only the ensureMessagesSuffix fix.

* fix: preserve pass-through for proxy URLs with /v1/ mid-path

Add back a Contains('/v1/') guard after the HasSuffix checks so that
proxy URLs like https://proxy.com/v1/anthropic are returned as-is
instead of getting /v1/messages appended.

* test: add proxy URL with /v1/ mid-path test case
2026-07-28 11:14:23 +08:00
..
bpe_data feat: init 2026-05-20 22:03:52 +08:00
client.go fix(llmloop): guard nil tool-call arguments map to prevent panic (#393) 2026-07-21 13:24:50 +08:00
client_test.go fix(llmloop): guard nil tool-call arguments map to prevent panic (#393) 2026-07-21 13:24:50 +08:00
embedded_loader.go feat: init 2026-05-20 22:03:52 +08:00
embedded_loader_test.go test: add coverage tests for agent, llm, llmloop, and scan packages 2026-06-27 00:15:28 +08:00
message_test.go test: fix golangci-lint errcheck/staticcheck issues in test code (#323) 2026-07-08 22:46:18 +08:00
protocol.go feat: Add OpenAI Responses API support and refactor protocol handling (#363) 2026-07-15 12:54:52 +08:00
protocol_test.go feat: Add OpenAI Responses API support and refactor protocol handling (#363) 2026-07-15 12:54:52 +08:00
providers.go feat(llm): add iFlytek Spark as a built-in provider (#485) 2026-07-24 23:41:16 +08:00
providers_test.go feat(llm): add iFlytek Spark as a built-in provider (#485) 2026-07-24 23:41:16 +08:00
resolver.go fix: ensureMessagesSuffix double-paths URLs ending with /v1 (#533) 2026-07-28 11:14:23 +08:00
resolver_test.go fix: ensureMessagesSuffix double-paths URLs ending with /v1 (#533) 2026-07-28 11:14:23 +08:00
responses_client.go feat: Add OpenAI Responses API support and refactor protocol handling (#363) 2026-07-15 12:54:52 +08:00
responses_client_test.go feat: Add OpenAI Responses API support and refactor protocol handling (#363) 2026-07-15 12:54:52 +08:00
usage_resolver.go feat: Add OpenAI Responses API support and refactor protocol handling (#363) 2026-07-15 12:54:52 +08:00
usage_resolver_test.go feat: Add OpenAI Responses API support and refactor protocol handling (#363) 2026-07-15 12:54:52 +08:00