mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-31 02:28:09 +08:00
Merge pull request #22604 from davelopez/26.0/fix_forum_error_handling
[26.0] Fix error handling for Help Forum integration
This commit is contained in:
@@ -6,10 +6,12 @@ import { computed, onMounted, ref } from "vue";
|
||||
import { GalaxyApi } from "@/api";
|
||||
import { galaxyLogo } from "@/components/icons/galaxyIcons";
|
||||
import { useConfigStore } from "@/stores/configurationStore";
|
||||
import { errorMessageAsString } from "@/utils/simple-error";
|
||||
import { getShortToolId } from "@/utils/tool";
|
||||
|
||||
import { createTopicUrl, type HelpForumPost, type HelpForumTopic, useHelpURLs } from "./helpForumUrls";
|
||||
|
||||
import Alert from "@/components/Alert.vue";
|
||||
import Heading from "@/components/Common/Heading.vue";
|
||||
import ExternalLink from "@/components/ExternalLink.vue";
|
||||
|
||||
@@ -22,6 +24,7 @@ const toolHelpTag = "tool-help";
|
||||
|
||||
const topics = ref<HelpForumTopic[]>([]);
|
||||
const posts = ref<HelpForumPost[]>([]);
|
||||
const errorMessage = ref("");
|
||||
const helpAvailable = computed(() => topics.value.length > 0);
|
||||
|
||||
const root = ref(null);
|
||||
@@ -36,7 +39,7 @@ onMounted(async () => {
|
||||
},
|
||||
});
|
||||
if (error) {
|
||||
console.error("Error fetching help forum data", error);
|
||||
errorMessage.value = errorMessageAsString(error, "Failed to search the Help Forum.");
|
||||
}
|
||||
|
||||
topics.value = data?.topics ?? [];
|
||||
@@ -66,12 +69,14 @@ const configStore = useConfigStore();
|
||||
<div ref="root" class="tool-help-forum mt-2 mb-4">
|
||||
<Heading h2 separator bold size="sm">Help Forum</Heading>
|
||||
|
||||
<Alert v-if="errorMessage" variant="warning" :message="errorMessage" />
|
||||
|
||||
<p v-if="helpAvailable">
|
||||
Following questions on the
|
||||
<ExternalLink :href="configStore.config.help_forum_api_url"> Help Forum </ExternalLink> may be related to
|
||||
this tool:
|
||||
</p>
|
||||
<p v-else>
|
||||
<p v-else-if="!errorMessage">
|
||||
There are no questions on the
|
||||
<ExternalLink :href="configStore.config.help_forum_api_url"> Help Forum </ExternalLink>
|
||||
about this tool.
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
import logging
|
||||
|
||||
from galaxy.config import GalaxyAppConfiguration
|
||||
from galaxy.exceptions import ServerNotConfiguredForRequest
|
||||
from galaxy.exceptions import (
|
||||
GatewayTimeoutException,
|
||||
InternalServerError,
|
||||
ServerNotConfiguredForRequest,
|
||||
UpstreamProxyError,
|
||||
)
|
||||
from galaxy.schema.help import HelpForumSearchResponse
|
||||
from galaxy.security.idencoding import IdEncodingHelper
|
||||
from galaxy.util import requests
|
||||
@@ -34,10 +39,35 @@ class HelpService(ServiceBase):
|
||||
if not self.config.help_forum_api_url:
|
||||
raise ServerNotConfiguredForRequest("Help forum API URL is not configured.")
|
||||
forum_search_url = f"{self.config.help_forum_api_url}/search.json"
|
||||
response = requests.get(
|
||||
url=forum_search_url,
|
||||
params={
|
||||
"q": query,
|
||||
},
|
||||
)
|
||||
return HelpForumSearchResponse(**response.json())
|
||||
try:
|
||||
response = requests.get(
|
||||
url=forum_search_url,
|
||||
params={
|
||||
"q": query,
|
||||
},
|
||||
)
|
||||
except requests.exceptions.ConnectionError:
|
||||
raise UpstreamProxyError(
|
||||
"Could not connect to the Galaxy Help Forum. The service may be temporarily unavailable."
|
||||
)
|
||||
except requests.exceptions.Timeout:
|
||||
raise GatewayTimeoutException("The request to the Galaxy Help Forum timed out. Please try again later.")
|
||||
except requests.exceptions.RequestException as e:
|
||||
raise InternalServerError(f"An error occurred while requesting the Galaxy Help Forum: {e}")
|
||||
|
||||
if not response.ok:
|
||||
if 400 <= response.status_code < 500:
|
||||
raise InternalServerError(
|
||||
f"The Galaxy Help Forum returned an error (HTTP {response.status_code}). "
|
||||
"This may indicate a misconfigured URL or API key that requires admin intervention."
|
||||
)
|
||||
else:
|
||||
raise UpstreamProxyError(
|
||||
f"The Galaxy Help Forum returned an error (HTTP {response.status_code}). "
|
||||
"The service may be temporarily unavailable. Please try again later."
|
||||
)
|
||||
|
||||
try:
|
||||
return HelpForumSearchResponse(**response.json())
|
||||
except ValueError as e:
|
||||
raise InternalServerError(f"Received an unexpected response format from the Galaxy Help Forum: {e}")
|
||||
|
||||
Reference in New Issue
Block a user