mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-13 04:04:44 +00:00
chore: kill old copilot 403 message that was used for old plugin migration (#16904)
This commit is contained in:
@@ -40,14 +40,6 @@ export namespace ProviderError {
|
|||||||
return /^4(00|13)\s*(status code)?\s*\(no body\)/i.test(message)
|
return /^4(00|13)\s*(status code)?\s*\(no body\)/i.test(message)
|
||||||
}
|
}
|
||||||
|
|
||||||
function error(providerID: string, error: APICallError) {
|
|
||||||
if (providerID.includes("github-copilot") && error.statusCode === 403) {
|
|
||||||
return "Please reauthenticate with the copilot provider to ensure your credentials work properly with OpenCode."
|
|
||||||
}
|
|
||||||
|
|
||||||
return error.message
|
|
||||||
}
|
|
||||||
|
|
||||||
function message(providerID: string, e: APICallError) {
|
function message(providerID: string, e: APICallError) {
|
||||||
return iife(() => {
|
return iife(() => {
|
||||||
const msg = e.message
|
const msg = e.message
|
||||||
@@ -60,10 +52,6 @@ export namespace ProviderError {
|
|||||||
return "Unknown error"
|
return "Unknown error"
|
||||||
}
|
}
|
||||||
|
|
||||||
const transformed = error(providerID, e)
|
|
||||||
if (transformed !== msg) {
|
|
||||||
return transformed
|
|
||||||
}
|
|
||||||
if (!e.responseBody || (e.statusCode && msg !== STATUS_CODES[e.statusCode])) {
|
if (!e.responseBody || (e.statusCode && msg !== STATUS_CODES[e.statusCode])) {
|
||||||
return msg
|
return msg
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -842,35 +842,6 @@ describe("session.message-v2.fromError", () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
test("maps github-copilot 403 to reauth guidance", () => {
|
|
||||||
const error = new APICallError({
|
|
||||||
message: "forbidden",
|
|
||||||
url: "https://api.githubcopilot.com/v1/chat/completions",
|
|
||||||
requestBodyValues: {},
|
|
||||||
statusCode: 403,
|
|
||||||
responseHeaders: { "content-type": "application/json" },
|
|
||||||
responseBody: '{"error":"forbidden"}',
|
|
||||||
isRetryable: false,
|
|
||||||
})
|
|
||||||
|
|
||||||
const result = MessageV2.fromError(error, { providerID: "github-copilot" })
|
|
||||||
|
|
||||||
expect(result).toStrictEqual({
|
|
||||||
name: "APIError",
|
|
||||||
data: {
|
|
||||||
message:
|
|
||||||
"Please reauthenticate with the copilot provider to ensure your credentials work properly with OpenCode.",
|
|
||||||
statusCode: 403,
|
|
||||||
isRetryable: false,
|
|
||||||
responseHeaders: { "content-type": "application/json" },
|
|
||||||
responseBody: '{"error":"forbidden"}',
|
|
||||||
metadata: {
|
|
||||||
url: "https://api.githubcopilot.com/v1/chat/completions",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
test("detects context overflow from APICallError provider messages", () => {
|
test("detects context overflow from APICallError provider messages", () => {
|
||||||
const cases = [
|
const cases = [
|
||||||
"prompt is too long: 213462 tokens > 200000 maximum",
|
"prompt is too long: 213462 tokens > 200000 maximum",
|
||||||
|
|||||||
Reference in New Issue
Block a user