Skip to content

Automate browser based workflows with AI

fix: prevent settings page crash for self-hosted users (#5164)

Celal Zamanoğlua995b6e4d3b7
diff --git a/skyvern-frontend/src/routes/settings/Settings.tsx b/skyvern-frontend/src/routes/settings/Settings.tsx
index cd44dbf75..6cb16190d 100644
--- a/skyvern-frontend/src/routes/settings/Settings.tsx
+++ b/skyvern-frontend/src/routes/settings/Settings.tsx
@@ -20,7 +20,7 @@ import { OnePasswordTokenForm } from "@/components/OnePasswordTokenForm";
import { AzureClientSecretCredentialTokenForm } from "@/components/AzureClientSecretCredentialTokenForm";
import { CustomCredentialServiceConfigForm } from "@/components/CustomCredentialServiceConfigForm";
import { useVersionQuery } from "@/hooks/useVersionQuery";
-import { formatVersion } from "@/util/version";
+import { formatVersion, getAppVersion } from "@/util/version";
function Settings() {
const { environment, organization, setEnvironment, setOrganization } =
@@ -112,12 +112,12 @@ function Settings() {
<CustomCredentialServiceConfigForm />
</CardContent>
</Card>
- {(__APP_VERSION__ !== "development" || versionData?.version) && (
+ {(getAppVersion() !== "development" || versionData?.version) && (
<p className="text-center text-xs text-muted-foreground/50">
- {__APP_VERSION__ !== "development" && (
- <>UI: {formatVersion(__APP_VERSION__)}</>
+ {getAppVersion() !== "development" && (
+ <>UI: {formatVersion(getAppVersion())}</>
)}
- {__APP_VERSION__ !== "development" && versionData?.version && " | "}
+ {getAppVersion() !== "development" && versionData?.version && " | "}
{versionData?.version && (
<>API: {formatVersion(versionData.version)}</>
)}
diff --git a/skyvern-frontend/src/util/version.ts b/skyvern-frontend/src/util/version.ts
index e973f5975..2b4e79075 100644
--- a/skyvern-frontend/src/util/version.ts
+++ b/skyvern-frontend/src/util/version.ts
@@ -6,4 +6,19 @@ function formatVersion(version: string): string {
return version;
}
-export { formatVersion };
+/**
+ * Safely access the build-time __APP_VERSION__ global.
+ *
+ * Vite's `define` does literal text replacement at build time. If the build
+ * was produced without the `define` entry (e.g. self-hosted Docker images
+ * built before the config was updated), the bare global reference throws a
+ * ReferenceError at runtime. `typeof` on an undeclared variable returns
+ * "undefined" without throwing, so this accessor is always safe.
+ */
+function getAppVersion(): string {
+ return typeof __APP_VERSION__ !== "undefined"
+ ? __APP_VERSION__
+ : "development";
+}
+
+export { formatVersion, getAppVersion };