Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

fix(web): gate SystemOne/RAGcon model listing on api key presence (#21475)

chanx54ad4ffa38e2
diff --git a/web/src/constants/llm.ts b/web/src/constants/llm.ts
index aaa6d347ee..1e509788b1 100644
--- a/web/src/constants/llm.ts
+++ b/web/src/constants/llm.ts
@@ -117,6 +117,7 @@ export enum LLMFactory {
EmpirioLabs = 'EmpirioLabs AI',
AIStupidLevel = 'AI Stupid Level',
Runcrate = 'Runcrate',
+ SystemOne = 'SystemOne',
}
// Please lowercase the file name
diff --git a/web/src/pages/user-setting/setting-model/instance-card/models-section/hooks.test.tsx b/web/src/pages/user-setting/setting-model/instance-card/models-section/hooks.test.tsx
index e95f2bd704..96a988f430 100644
--- a/web/src/pages/user-setting/setting-model/instance-card/models-section/hooks.test.tsx
+++ b/web/src/pages/user-setting/setting-model/instance-card/models-section/hooks.test.tsx
@@ -58,7 +58,11 @@ jest.mock('@/hooks/use-llm-request', () => ({
}),
}));
-jest.mock('@/components/dynamic-form', () => ({}));
+// The module chain under test (instance-card/hooks -> provider-schema field
+// configs) reads `FormFieldType` at import time, so the stub must expose it.
+jest.mock('@/components/dynamic-form', () => ({
+ FormFieldType: new Proxy({}, { get: (_t, key) => String(key) }),
+}));
jest.mock('../../provider-schema/hooks', () => ({
useProviderFields: jest.fn(),
@@ -121,6 +125,7 @@ describe('Bedrock model credentials', () => {
provider_name: 'Bedrock',
api_key: apiKey,
base_url: undefined,
+ instance_name: 'bedrock-instance',
}),
);
});
@@ -217,6 +222,113 @@ describe('Bedrock model credentials', () => {
});
});
+describe('API-key-gated model listing (SystemOne / RAGcon)', () => {
+ beforeEach(() => {
+ mockListProviderModels.mockReset().mockResolvedValue({ code: 0, data: [] });
+ });
+
+ it('defers the SystemOne auto-fetch until an api_key is available', async () => {
+ let apiKey = '';
+ const resolveCreds = () => ({ apiKey, baseUrl: undefined });
+
+ const { rerender } = renderHook(
+ ({ apiKeyValue }) =>
+ useModelsCatalog({
+ providerName: 'SystemOne',
+ instanceName: DRAFT_INSTANCE_SENTINEL,
+ hideActions: false,
+ resolveCreds,
+ instanceModels: undefined,
+ apiKeyValue,
+ baseUrlValue: undefined,
+ }),
+ { initialProps: { apiKeyValue: apiKey } },
+ );
+
+ expect(mockListProviderModels).not.toHaveBeenCalled();
+
+ apiKey = 'draft-key';
+ rerender({ apiKeyValue: apiKey });
+
+ await waitFor(() =>
+ expect(mockListProviderModels).toHaveBeenCalledWith({
+ provider_name: 'SystemOne',
+ api_key: apiKey,
+ base_url: undefined,
+ }),
+ );
+ });
+
+ it('defers the RAGcon auto-fetch when base_url is set but api_key is missing', async () => {
+ let apiKey = '';
+ const baseUrl = 'https://api.ragcon.ai/v1';
+ const resolveCreds = () => ({ apiKey, baseUrl });
+
+ const { rerender } = renderHook(
+ ({ apiKeyValue }) =>
+ useModelsCatalog({
+ providerName: 'RAGcon',
+ instanceName: DRAFT_INSTANCE_SENTINEL,
+ hideActions: false,
+ resolveCreds,
+ instanceModels: undefined,
+ apiKeyValue,
+ baseUrlValue: baseUrl,
+ }),
+ { initialProps: { apiKeyValue: apiKey } },
+ );
+
+ // base_url alone must not trigger the fetch — the key gate still applies.
+ expect(mockListProviderModels).not.toHaveBeenCalled();
+
+ apiKey = 'draft-key';
+ rerender({ apiKeyValue: apiKey });
+
+ await waitFor(() =>
+ expect(mockListProviderModels).toHaveBeenCalledWith({
+ provider_name: 'RAGcon',
+ api_key: apiKey,
+ base_url: baseUrl,
+ }),
+ );
+ });
+
+ it('auto-fetches a saved RAGcon instance once its stored api_key loads', async () => {
+ let apiKey = '';
+ const baseUrl = 'https://api.ragcon.ai/v1';
+ const resolveCreds = () => ({ apiKey, baseUrl });
+
+ const { rerender } = renderHook(
+ ({ apiKeyValue, instanceDetailsLoaded }) =>
+ useModelsCatalog({
+ providerName: 'RAGcon',
+ instanceName: 'ragcon-instance',
+ hideActions: false,
+ resolveCreds,
+ instanceModels: undefined,
+ apiKeyValue,
+ baseUrlValue: baseUrl,
+ instanceDetailsLoaded,
+ }),
+ { initialProps: { apiKeyValue: apiKey, instanceDetailsLoaded: false } },
+ );
+
+ expect(mockListProviderModels).not.toHaveBeenCalled();
+
+ apiKey = 'saved-key';
+ rerender({ apiKeyValue: apiKey, instanceDetailsLoaded: true });
+
+ await waitFor(() =>
+ expect(mockListProviderModels).toHaveBeenCalledWith({
+ provider_name: 'RAGcon',
+ api_key: apiKey,
+ base_url: baseUrl,
+ instance_name: 'ragcon-instance',
+ }),
+ );
+ });
+});
+
describe('saved instance model baseline', () => {
it('does not accept a failed model query as an authoritative snapshot', () => {
const onInstanceModelsEdited = jest.fn();
diff --git a/web/src/pages/user-setting/setting-model/instance-card/models-section/hooks.ts b/web/src/pages/user-setting/setting-model/instance-card/models-section/hooks.ts
index 612cc63258..967255aa0d 100644
--- a/web/src/pages/user-setting/setting-model/instance-card/models-section/hooks.ts
+++ b/web/src/pages/user-setting/setting-model/instance-card/models-section/hooks.ts
@@ -52,6 +52,18 @@ const TOOL_FEATURE_KEYS = ['is_tools', 'tool_call', 'tools', 'function_call'];
/** Sentinel instance name used by draft (unsaved) provider cards. */
export const DRAFT_INSTANCE_SENTINEL = '__draft__';
+/**
+ * Providers whose model listing is meaningful only when an api-key exists
+ * (typed into the draft form or returned with the saved instance details).
+ * Opening their cards without a key would fire a list request the upstream
+ * rejects, so — like VolcEngine — the auto-fetch waits for the key.
+ */
+export const API_KEY_GATED_LIST_PROVIDERS: string[] = [
+ LLMFactory.SystemOne,
+ LLMFactory.RAGcon,
+ LLMFactory.VolcEngine,
+];
+
// ---------------------------------------------------------------------------
// Pure helpers (no React state, easy to test)
// ---------------------------------------------------------------------------
@@ -266,7 +278,8 @@ export function useModelsCatalog({
};
// Auto-fetch the provider's available-models catalog when this section
- // mounts (effectively "when the card is expanded"). For VolcEngine we
+ // mounts (effectively "when the card is expanded"). For VolcEngine and the
+ // providers in API_KEY_GATED_LIST_PROVIDERS (SystemOne, RAGcon) we
// wait until an api_key is available (typed in the draft form or loaded
// from instance details). For providers whose form includes a
// `base_url` field (e.g. Ollama, Xinference, LocalAI) we defer until a
@@ -295,7 +308,7 @@ export function useModelsCatalog({
? (creds.apiKey as Record<string, unknown>)
: undefined;
const requiresApiKey =
- providerName === LLMFactory.VolcEngine ||
+ API_KEY_GATED_LIST_PROVIDERS.includes(providerName) ||
(providerName === LLMFactory.Bedrock &&
apiKeyConfig?.auth_mode === 'bedrock_api_key');
const hasApiKey =