LibreChat/e2e/specs/mock/completion.spec.ts
Marco Beretta 9633edcb88
🗣️ fix: Keep Provider Error Text on Unclassified Agent Failures (#16034)
* 🗣️ fix: Keep Provider Error Text on Unclassified Agent Failures

An upstream failure LangChain does not classify discarded the provider's own
message and answered with the generic upstream sentence plus a status, so a
gateway or privacy-proxy rejection lost the only account of what happened.

The provider text now rides along in the persisted payload as `message`,
withheld only where a content policy inspects the traffic — the same condition
`getUserFacingProviderError` and `getUserFacingRequestError` already decide by.

* fix: Harden Provider Error Detail Retention

---------

Co-authored-by: Danny Avila <danny@librechat.ai>
2026-09-16 21:32:41 -04:00

30 lines
1.1 KiB
TypeScript

import { expect, test } from '@playwright/test';
import {
MOCK_ENDPOINTS,
NEW_CHAT_PATH,
messagesView,
selectMockEndpoint,
sendMessageAndWaitForCompletion,
} from './helpers';
test.describe('generation finalization invariant', () => {
test('rejects a persisted assistant error after successful generation admission', async ({
page,
}) => {
test.setTimeout(90_000);
const label = `completion-error-${Date.now()}`;
const providerError = `E2E forced stream error ${label}`;
await page.goto(NEW_CHAT_PATH, { timeout: 10000 });
await selectMockEndpoint(page, MOCK_ENDPOINTS[0]);
await expect(
sendMessageAndWaitForCompletion(page, `E2E_FORCED_ERROR:${label}`),
).rejects.toThrow('Persisted assistant response contains an unexpected error');
await expect(
messagesView(page).getByText('The model provider could not complete this request.'),
).toBeVisible();
/** No content policy is configured here, so the provider's own words reach the reader. */
await expect(messagesView(page).getByText(providerError)).toBeVisible();
});
});