You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ru...@apache.org on 2026/08/11 00:41:40 UTC
(superset) branch master updated: fix(theming): guard ensureStaticPrefix against null/undefined input (#43019)
This is an automated email from the ASF dual-hosted git repository.
rusackas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new bfa1e775c4d fix(theming): guard ensureStaticPrefix against null/undefined input (#43019)
bfa1e775c4d is described below
commit bfa1e775c4ddc6f8e18893582549e15d9ac8f313
Author: Evan Rusackas <ev...@preset.io>
AuthorDate: Mon Aug 10 17:41:33 2026 -0700
fix(theming): guard ensureStaticPrefix against null/undefined input (#43019)
Co-authored-by: Claude Sonnet 5 <no...@anthropic.com>
---
superset-frontend/src/utils/assetUrl.test.ts | 10 ++++++++++
superset-frontend/src/utils/assetUrl.ts | 10 +++++++++-
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/superset-frontend/src/utils/assetUrl.test.ts b/superset-frontend/src/utils/assetUrl.test.ts
index 3d8307f6b3b..9c952a40f77 100644
--- a/superset-frontend/src/utils/assetUrl.test.ts
+++ b/superset-frontend/src/utils/assetUrl.test.ts
@@ -84,4 +84,14 @@ describe('ensureStaticPrefix should be idempotent', () => {
staticAssetsPrefixMock.mockReturnValue('');
expect(ensureStaticPrefix('/static/x.png')).toBe('/static/x.png');
});
+
+ test('returns undefined instead of throwing when passed undefined', () => {
+ staticAssetsPrefixMock.mockReturnValue('/superset');
+ expect(ensureStaticPrefix(undefined)).toBeUndefined();
+ });
+
+ test('returns undefined instead of throwing when passed null', () => {
+ staticAssetsPrefixMock.mockReturnValue('/superset');
+ expect(ensureStaticPrefix(null)).toBeUndefined();
+ });
});
diff --git a/superset-frontend/src/utils/assetUrl.ts b/superset-frontend/src/utils/assetUrl.ts
index 72a07eff5bd..abe886f6bdd 100644
--- a/superset-frontend/src/utils/assetUrl.ts
+++ b/superset-frontend/src/utils/assetUrl.ts
@@ -35,9 +35,17 @@ export function assetUrl(path: string): string {
* segment boundary is returned unchanged, mirroring the dedupe pattern used by
* `ensureAppRoot` in pathUtils.ts and `SupersetClient.getUrl`.
*
+ * If `url_or_path` is null or undefined, `undefined` is returned so callers
+ * (e.g. a partial theme reaching the frontend from a source other than
+ * `superset_config.py`, such as a DB-stored theme created via the API) don't
+ * crash on the unconditional `.startsWith()` call below.
+ *
* @param url_or_path A url or relative path to a resource
*/
-export function ensureStaticPrefix(url_or_path: string): string {
+export function ensureStaticPrefix(
+ url_or_path: string | null | undefined,
+): string | undefined {
+ if (url_or_path == null) return undefined;
if (!url_or_path.startsWith('/')) return url_or_path;
const prefix = staticAssetsPrefix();
if (