Skip to content

πŸ™Œ OpenHands: AI-Driven Development

hotfix(frontend): Return DEFAULT_SETTINGS if GET /settings is 404 (#6517)

sp.wack28d7127257fd
diff --git a/frontend/src/hooks/query/use-settings.ts b/frontend/src/hooks/query/use-settings.ts
index 84ef1cb690..32b6f338e1 100644
--- a/frontend/src/hooks/query/use-settings.ts
+++ b/frontend/src/hooks/query/use-settings.ts
@@ -1,41 +1,25 @@
import { useQuery } from "@tanstack/react-query";
import React from "react";
import posthog from "posthog-js";
-import { AxiosError } from "axios";
import { DEFAULT_SETTINGS } from "#/services/settings";
import OpenHands from "#/api/open-hands";
import { useAuth } from "#/context/auth-context";
const getSettingsQueryFn = async () => {
- try {
- const apiSettings = await OpenHands.getSettings();
-
- if (apiSettings !== null) {
- return {
- LLM_MODEL: apiSettings.llm_model,
- LLM_BASE_URL: apiSettings.llm_base_url,
- AGENT: apiSettings.agent,
- LANGUAGE: apiSettings.language,
- CONFIRMATION_MODE: apiSettings.confirmation_mode,
- SECURITY_ANALYZER: apiSettings.security_analyzer,
- LLM_API_KEY: apiSettings.llm_api_key,
- REMOTE_RUNTIME_RESOURCE_FACTOR:
- apiSettings.remote_runtime_resource_factor,
- GITHUB_TOKEN_IS_SET: apiSettings.github_token_is_set,
- ENABLE_DEFAULT_CONDENSER: apiSettings.enable_default_condenser,
- };
- }
-
- return DEFAULT_SETTINGS;
- } catch (error) {
- if (error instanceof AxiosError) {
- if (error.response?.status === 404) {
- return DEFAULT_SETTINGS;
- }
- }
-
- throw error;
- }
+ const apiSettings = await OpenHands.getSettings();
+
+ return {
+ LLM_MODEL: apiSettings.llm_model,
+ LLM_BASE_URL: apiSettings.llm_base_url,
+ AGENT: apiSettings.agent,
+ LANGUAGE: apiSettings.language,
+ CONFIRMATION_MODE: apiSettings.confirmation_mode,
+ SECURITY_ANALYZER: apiSettings.security_analyzer,
+ LLM_API_KEY: apiSettings.llm_api_key,
+ REMOTE_RUNTIME_RESOURCE_FACTOR: apiSettings.remote_runtime_resource_factor,
+ GITHUB_TOKEN_IS_SET: apiSettings.github_token_is_set,
+ ENABLE_DEFAULT_CONDENSER: apiSettings.enable_default_condenser,
+ };
};
export const useSettings = () => {
diff --git a/frontend/src/query-client-config.ts b/frontend/src/query-client-config.ts
index cfb847e27d..afafcc62b1 100644
--- a/frontend/src/query-client-config.ts
+++ b/frontend/src/query-client-config.ts
@@ -1,7 +1,7 @@
import { QueryClientConfig, QueryCache } from "@tanstack/react-query";
import { renderToastIfError } from "./utils/render-toast-if-error";
-const QUERY_KEYS_TO_IGNORE = ["authenticated", "hosts"];
+const QUERY_KEYS_TO_IGNORE = ["authenticated", "hosts", "settings"];
export const queryClientConfig: QueryClientConfig = {
queryCache: new QueryCache({